To get the mean and variance in tensorflow just use tf.nn.moments.
mean, var = tf.nn.moments(x, axes=[1])
and in numpy mean, var =  np.std(x, axes=[1])
What is the equivalent function of getting variance in pytorch?