class_docstr: The Batch-Reshaping distribution.
  
  This "meta-distribution" reshapes the batch dimensions of another
  distribution.
  
  #### Examples
  
  ```python
  tfd = tfp.distributions
  
  dtype = np.float32
  dims = 2
  new_batch_shape = [1, 2, -1]
  old_batch_shape = [6]
  
  scale = np.ones(old_batch_shape + [dims], dtype)
  mvn = tfd.MultivariateNormalDiag(scale_diag=scale)
  reshape_mvn = tfd.BatchReshape(
      distribution=mvn,
      batch_shape=new_batch_shape,
      validate_args=True)
  
  reshape_mvn.batch_shape
  # ==> [1, 2, 3]
  
  x = reshape_mvn.sample(sample_shape=[4, 5])
  x.shape
  # ==> [4, 5, 1, 2, 3, 2] == sample_shape + new_batch_shape + [dims]
  
  reshape_mvn.log_prob(x).shape
  # ==> [4, 5, 1, 2, 3] == sample_shape + new_batch_shape
  ```
class_docstr_tok: ["The","Batch-Reshaping","distribution",".","This","``","meta-distribution","''","reshapes","the","batch","dimensions","of","another","distribution",".","#","#","#","#","Examples","``","`","python","tfd","=","tfp.distributions","dtype","=","np.float32","dims","=","2","new_batch_shape","=","[","1",",","2",",","-1","]","old_batch_shape","=","[","6","]","scale","=","np.ones","(","old_batch_shape","+","[","dims","]",",","dtype",")","mvn","=","tfd.MultivariateNormalDiag","(","scale_diag=scale",")","reshape_mvn","=","tfd.BatchReshape","(","distribution=mvn",",","batch_shape=new_batch_shape",",","validate_args=True",")","reshape_mvn.batch_shape","#","==",">","[","1",",","2",",","3","]","x","=","reshape_mvn.sample","(","sample_shape=","[","4",",","5","]",")","x.shape","#","==",">","[","4",",","5",",","1",",","2",",","3",",","2","]","==","sample_shape","+","new_batch_shape","+","[","dims","]","reshape_mvn.log_prob","(","x",")",".shape","#","==",">","[","4",",","5",",","1",",","2",",","3","]","==","sample_shape","+","new_batch_shape","``","`"]
docstr: Construct BatchReshape distribution.
  
  Args:
    distribution: The base distribution instance to reshape. Typically an
      instance of `Distribution`.
    batch_shape: Positive `int`-like vector-shaped `Tensor` representing
      the new shape of the batch dimensions. Up to one dimension may contain
      `-1`, meaning the remainder of the batch size.
    validate_args: Python `bool`, default `False`. When `True` distribution
      parameters are checked for validity despite possibly degrading runtime
      performance. When `False` invalid inputs may silently render incorrect
      outputs.
    allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
      (e.g., mean, mode, variance) use the value `NaN` to indicate the
      result is undefined. When `False`, an exception is raised if one or
      more of the statistic's batch members are undefined.
    name: The name to give Ops created by the initializer.
      Default value: `"BatchReshape" + distribution.name`.
  
  Raises:
    ValueError: if `batch_shape` is not a vector.
    ValueError: if `batch_shape` has non-positive elements.
    ValueError: if `batch_shape` size is not the same as a
      `distribution.batch_shape` size.
docstr_tok: ["Construct","BatchReshape","distribution",".","Args",":","distribution",":","The","base","distribution","instance","to","reshape",".","Typically","an","instance","of","`","Distribution","`",".","batch_shape",":","Positive","`","int","`","-like","vector-shaped","`","Tensor","`","representing","the","new","shape","of","the","batch","dimensions",".","Up","to","one","dimension","may","contain","`","-1","`",",","meaning","the","remainder","of","the","batch","size",".","validate_args",":","Python","`","bool","`",",","default","`","False","`",".","When","`","True","`","distribution","parameters","are","checked","for","validity","despite","possibly","degrading","runtime","performance",".","When","`","False","`","invalid","inputs","may","silently","render","incorrect","outputs",".","allow_nan_stats",":","Python","`","bool","`",",","default","`","True","`",".","When","`","True","`",",","statistics","(","e.g.",",","mean",",","mode",",","variance",")","use","the","value","`","NaN","`","to","indicate","the","result","is","undefined",".","When","`","False","`",",","an","exception","is","raised","if","one","or","more","of","the","statistic","'s","batch","members","are","undefined",".","name",":","The","name","to","give","Ops","created","by","the","initializer",".","Default","value",":","`","``","BatchReshape","''","+","distribution.name","`",".","Raises",":","ValueError",":","if","`","batch_shape","`","is","not","a","vector",".","ValueError",":","if","`","batch_shape","`","has","non-positive","elements",".","ValueError",":","if","`","batch_shape","`","size","is","not","the","same","as","a","`","distribution.batch_shape","`","size","."]
code: def __init__(
      self,
      distribution,
      batch_shape,
      validate_args=False,
      allow_nan_stats=True,
      name=None,
  ):
      """Construct BatchReshape distribution.
  
      Args:
        distribution: The base distribution instance to reshape. Typically an
          instance of `Distribution`.
        batch_shape: Positive `int`-like vector-shaped `Tensor` representing
          the new shape of the batch dimensions. Up to one dimension may contain
          `-1`, meaning the remainder of the batch size.
        validate_args: Python `bool`, default `False`. When `True` distribution
          parameters are checked for validity despite possibly degrading runtime
          performance. When `False` invalid inputs may silently render incorrect
          outputs.
        allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
          (e.g., mean, mode, variance) use the value `NaN` to indicate the
          result is undefined. When `False`, an exception is raised if one or
          more of the statistic's batch members are undefined.
        name: The name to give Ops created by the initializer.
          Default value: `"BatchReshape" + distribution.name`.
  
      Raises:
        ValueError: if `batch_shape` is not a vector.
        ValueError: if `batch_shape` has non-positive elements.
        ValueError: if `batch_shape` size is not the same as a
          `distribution.batch_shape` size.
      """
      parameters = dict(locals())
      name = name or "BatchReshape" + distribution.name
      with tf.name_scope(name) as name:
          dtype = dtype_util.common_dtype(
              [batch_shape], dtype_hint=tf.int32
          )
          # The unexpanded batch shape may contain up to one dimension of -1.
          self._batch_shape_unexpanded = (
              tensor_util.convert_nonref_to_tensor(
                  batch_shape,
                  dtype=dtype,
                  name="batch_shape",
                  as_shape_tensor=True,
              )
          )
          validate_init_args_statically(
              distribution, self._batch_shape_unexpanded
          )
          self._distribution = distribution
          self._batch_shape_static = (
              tensorshape_util.constant_value_as_shape(
                  self._batch_shape_unexpanded
              )
          )
          super(_BatchReshape, self).__init__(
              dtype=distribution.dtype,
              reparameterization_type=distribution.reparameterization_type,
              validate_args=validate_args,
              allow_nan_stats=allow_nan_stats,
              parameters=parameters,
              name=name,
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  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 dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 1 to create a new _BatchReshape object from inherited base classes: distribution_lib with example: obj = _BatchReshape(distribution, batch_shape, validate_args, allow_nan_stats, name)