When calculating the reconstruction loss in C4_W3_Lab_1_VAE_MNIST, we are given the following code:
flattened_inputs = tf.reshape(x_batch_train, shape=[1])
flattened_outputs = tf.reshape(reconstructed, shape=[1])
loss = mse_loss(flattened_inputs, flattened_outputs) * 784
I do not understand:

What the purpose is of flattening the tensors before feeding them to mse_loss. I have experimented with adding the following 2 lines after the given loss calculation:
loss_b = mse_loss(x_batch_train, reconstructed) * 784 print( (loss_b.numpy()  loss.numpy()) / loss.numpy())
About half the time the relative difference is zero. The other times, the relative differences range from about 5e08 to 3e07. Both losses are tensors of shape=() and dtype=float32. So, why has the extra work been added? What am I missing?
 Why multiply by 784? Multiplying the loss function by a constant wonâ€™t change the location of the minimum, it will only change the value of that minimum. All this does is change the relative weights of the reconstuction loss and the KL loss. Is multiplying the reconstructive loss by the number of image pixels (i.e. 784 = 28 * 28) some sort of â€śbest practiceâ€ť?