class_docstr: Mixture distribution.
  
  The `Mixture` object implements batched mixture distributions.
  The mixture model is defined by a `Categorical` distribution (the mixture)
  and a python list of `Distribution` objects.
  
  In the common case that the component distributions are all the same
  `Distribution` class (potentially with different parameters), it's probably
  better to use `tfp.distributions.MixtureSameFamily` instead.
  
  Methods supported include `log_prob`, `prob`, `mean`, `sample`, and
  `entropy_lower_bound`.
  
  
  #### Examples
  
  ```python
  # Create a mixture of two Gaussians:
  tfd = tfp.distributions
  mix = 0.3
  bimix_gauss = tfd.Mixture(
    cat=tfd.Categorical(probs=[mix, 1.-mix]),
    components=[
      tfd.Normal(loc=-1., scale=0.1),
      tfd.Normal(loc=+1., scale=0.5),
  ])
  
  # Plot the PDF.
  import matplotlib.pyplot as plt
  x = tf.linspace(-2., 3., int(1e4))
  plt.plot(x, bimix_gauss.prob(x))
  ```
docstr: Initialize a Mixture distribution.
  
  A `Mixture` is defined by a `Categorical` (`cat`, representing the
  mixture probabilities) and a list of `Distribution` objects
  all having matching dtype, batch shape, event shape, support, and continuity
  properties (the components).
  
  The `num_classes` of `cat` must be possible to infer at graph construction
  time and match `len(components)`.
  
  In the common case that the component distributions are all the same
  `Distribution` class (potentially with different parameters), it's probably
  better to use `tfp.distributions.MixtureSameFamily` instead.
  
  Args:
    cat: A `Categorical` distribution instance, representing the probabilities
        of `distributions`.
    components: A list or tuple of `Distribution` instances.
      Each instance must have the same type, be defined on the same domain,
      and have matching `event_shape` and `batch_shape`.
    validate_args: Python `bool`, default `False`. If `True`, raise a runtime
      error if batch or event ranks are inconsistent between cat and any of
      the distributions. This is only checked if the ranks cannot be
      determined statically at graph construction time.
    allow_nan_stats: Boolean, default `True`. If `False`, raise an
     exception if a statistic (e.g. mean/mode/etc...) is undefined for any
      batch member. If `True`, batch members with valid parameters leading to
      undefined statistics will return NaN for this statistic.
    name: A name for this distribution (optional).
  
  Raises:
    TypeError: If cat is not a `Categorical`, or `components` is not
      a list or tuple, or the elements of `components` are not
      instances of `Distribution`, or do not have matching `dtype`.
    ValueError: If `components` is an empty list or tuple, or its
      elements do not have a statically known event rank.
      If `cat.num_classes` cannot be inferred at graph creation time,
      or the constant value of `cat.num_classes` is not equal to
      `len(components)`, or all `components` and `cat` do not have
      matching static batch shapes, or all components do not
      have matching static event shapes.
code: def __init__(
      self,
      cat,
      components,
      validate_args=False,
      allow_nan_stats=True,
      name="Mixture",
  ):
      """Initialize a Mixture distribution.
  
      A `Mixture` is defined by a `Categorical` (`cat`, representing the
      mixture probabilities) and a list of `Distribution` objects
      all having matching dtype, batch shape, event shape, support, and continuity
      properties (the components).
  
      The `num_classes` of `cat` must be possible to infer at graph construction
      time and match `len(components)`.
  
      In the common case that the component distributions are all the same
      `Distribution` class (potentially with different parameters), it's probably
      better to use `tfp.distributions.MixtureSameFamily` instead.
  
      Args:
        cat: A `Categorical` distribution instance, representing the probabilities
            of `distributions`.
        components: A list or tuple of `Distribution` instances.
          Each instance must have the same type, be defined on the same domain,
          and have matching `event_shape` and `batch_shape`.
        validate_args: Python `bool`, default `False`. If `True`, raise a runtime
          error if batch or event ranks are inconsistent between cat and any of
          the distributions. This is only checked if the ranks cannot be
          determined statically at graph construction time.
        allow_nan_stats: Boolean, default `True`. If `False`, raise an
         exception if a statistic (e.g. mean/mode/etc...) is undefined for any
          batch member. If `True`, batch members with valid parameters leading to
          undefined statistics will return NaN for this statistic.
        name: A name for this distribution (optional).
  
      Raises:
        TypeError: If cat is not a `Categorical`, or `components` is not
          a list or tuple, or the elements of `components` are not
          instances of `Distribution`, or do not have matching `dtype`.
        ValueError: If `components` is an empty list or tuple, or its
          elements do not have a statically known event rank.
          If `cat.num_classes` cannot be inferred at graph creation time,
          or the constant value of `cat.num_classes` is not equal to
          `len(components)`, or all `components` and `cat` do not have
          matching static batch shapes, or all components do not
          have matching static event shapes.
      """
      parameters = dict(locals())
      with tf.name_scope(name) as name:
          dtype = components[0].dtype
          if not all(d.dtype == dtype for d in components):
              raise TypeError(
                  "All components must have the same dtype, but saw "
                  "dtypes: %s" % [(d.name, d.dtype) for d in components]
              )
  
          static_event_shape = components[0].event_shape
          static_batch_shape = cat.batch_shape
          for di, d in enumerate(components):
              if not tensorshape_util.is_compatible_with(
                  static_batch_shape, d.batch_shape
              ):
                  raise ValueError(
                      "components[{}] batch shape must be compatible with cat "
                      "shape and other component batch shapes ({} vs {})".format(
                          di, static_batch_shape, d.batch_shape
                      )
                  )
              if not tensorshape_util.is_compatible_with(
                  static_event_shape, d.event_shape
              ):
                  raise ValueError(
                      "components[{}] event shape must be compatible with other "
                      "component event shapes ({} vs {})".format(
                          di, static_event_shape, d.event_shape
                      )
                  )
              static_event_shape = tensorshape_util.merge_with(
                  static_event_shape, d.event_shape
              )
              static_batch_shape = tensorshape_util.merge_with(
                  static_batch_shape, d.batch_shape
              )
          if tensorshape_util.rank(static_event_shape) is None:
              raise ValueError(
                  "Expected to know rank(event_shape) from components, but "
                  "none of the components provide a static number of ndims"
              )
  
          # pylint: disable=protected-access
          cat_dist_param = (
              cat._probs if cat._logits is None else cat._logits
          )
          # pylint: enable=protected-access
          static_num_components = tf.compat.dimension_value(
              cat_dist_param.shape[-1]
          )
          if static_num_components is None:
              raise ValueError(
                  "Could not infer number of classes from cat and unable "
                  "to compare this value to the number of components passed in."
              )
          if static_num_components != len(components):
              raise ValueError(
                  "cat.num_classes != len(components): %d vs. %d"
                  % (static_num_components, len(components))
              )
  
          self._cat = cat
          self._components = list(components)
          self._num_components = static_num_components
          self._static_event_shape = static_event_shape
          self._static_batch_shape = static_batch_shape
  
          super(_Mixture, self).__init__(
              dtype=dtype,
              reparameterization_type=reparameterization.NOT_REPARAMETERIZED,
              validate_args=validate_args,
              allow_nan_stats=allow_nan_stats,
              parameters=parameters,
              name=name,
          )
  
imports: import warnings
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import auto_composite_tensor
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.util.seed_stream import SeedStream
  from tensorflow_probability.python.util.seed_stream import TENSOR_SEED_MSG_PREFIX
label_desc: Use image node_id 1 to create a new _Mixture object from inherited base classes: distribution with example: obj = _Mixture(cat, components, validate_args, allow_nan_stats, name)