code: def testMeanMultivariate(self):
      for batch_shape in ((), (2,), (2, 3)):
          dist = make_multivariate_mixture(
              batch_shape=batch_shape,
              num_components=2,
              event_shape=(4,),
          )
          mean = dist.mean()
          self.assertEqual(batch_shape + (4,), mean.shape)
  
          cat_probs = tf.math.softmax(dist.cat.logits)
          dist_means = [d.mean() for d in dist.components]
  
          mean_value, cat_probs_value, dist_means_value = self.evaluate(
              [mean, cat_probs, dist_means]
          )
          self.assertEqual(batch_shape + (4,), mean_value.shape)
  
          cat_probs_value = _swap_first_last_axes(cat_probs_value)
  
          # Add a new innermost dimension for broadcasting to mvn vector shape
          cat_probs_value = [
              np.expand_dims(c_p, -1) for c_p in cat_probs_value
          ]
  
          true_mean = sum(
              [
                  c_p * m
                  for (c_p, m) in zip(cat_probs_value, dist_means_value)
              ]
          )
  
          self.assertAllClose(true_mean, mean_value)
  
imports: import contextlib
  import warnings
  import numpy
  from scipy import stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import dirichlet
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import half_normal
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import mixture
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 7 for calling the MixtureTest obj's underlying member method code with example usage: obj.testMeanMultivariate() without return types