code: def make_multivariate_mixture(
      batch_shape, num_components, event_shape, batch_shape_tensor=None
  ):
      if batch_shape_tensor is None:
          batch_shape_tensor = batch_shape
      batch_shape_tensor = tf.convert_to_tensor(
          value=batch_shape_tensor, dtype=tf.int32
      )
      seed_stream = test_util.test_seed_stream("multivariate_mixture")
      logits = -50.0 + tf.random.uniform(
          tf.concat((batch_shape_tensor, [num_components]), 0),
          -1,
          1,
          dtype=tf.float32,
          seed=seed_stream(),
      )
      tensorshape_util.set_shape(
          logits,
          tensorshape_util.concatenate(batch_shape, num_components),
      )
      static_batch_and_event_shape = tf.TensorShape(
          batch_shape
      ).concatenate(event_shape)
      event_shape = tf.convert_to_tensor(
          value=event_shape, dtype=tf.int32
      )
      batch_and_event_shape = tf.concat(
          (batch_shape_tensor, event_shape), 0
      )
  
      def create_component():
          loc = tf.random.normal(
              batch_and_event_shape, seed=seed_stream()
          )
          scale_diag = 10 * tf.random.uniform(
              batch_and_event_shape, seed=seed_stream()
          )
          tensorshape_util.set_shape(loc, static_batch_and_event_shape)
          tensorshape_util.set_shape(
              scale_diag, static_batch_and_event_shape
          )
          return mvn_diag.MultivariateNormalDiag(
              loc=loc, scale_diag=scale_diag, validate_args=True
          )
  
      components = [create_component() for _ in range(num_components)]
      cat = categorical.Categorical(logits, dtype=tf.int32)
      return mixture.Mixture(cat, components, validate_args=True)
  
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 a global function with example usage: make_multivariate_mixture(batch_shape, num_components, event_shape, batch_shape_tensor) and returns: mixture, mvn_diag