code: def testMatchingComponentsSizeAssertions(self):
      logits = self._build_variable(np.zeros(5))
      loc = self._build_variable(
          np.zeros((4, 5, 2, 3)), static_rank=True
      )
      scale = self._build_variable(1.0)
      dist = mixture_same_family.MixtureSameFamily(
          mixture_distribution=categorical.Categorical(logits=logits),
          components_distribution=independent.Independent(
              logistic.Logistic(loc=loc, scale=scale),
              reinterpreted_batch_ndims=2,
          ),
          validate_args=True,
      )
  
      self.evaluate([v.initializer for v in [logits, loc, scale]])
      self.evaluate(dist.mean())
  
      msg = (
          "`mixture_distribution` components.* does not equal "
          r"`components_distribution.batch_shape\[-1\]`"
      )
      with self.assertRaisesRegex(Exception, msg):
          with tf.control_dependencies(
              [loc.assign(np.zeros((4, 7, 2, 3)))]
          ):
              self.evaluate(dist.mean())
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import dirichlet
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import logistic
  from tensorflow_probability.python.distributions import mixture_same_family
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 1 for calling the MixtureSameFamilyTestDynamic32 obj's underlying member method code with example usage: obj.testMatchingComponentsSizeAssertions() without return types