code: def batch_slice(
      batch_object,
      params_overrides,
      slices,
      bijector_x_event_ndims=None,
  ):
      """Slices `batch_object` along its batch dimensions.
  
      Args:
        batch_object: A `tfd.Distribution` instance.
        params_overrides: A `dict` of parameter overrides. (e.g. from
          `Distribution.copy`).
        slices: A `slice` or `int` or `int` `Tensor` or `tf.newaxis` or `tuple`
          thereof. (e.g. the argument of a `__getitem__` method).
        bijector_x_event_ndims: If `batch_object` is a bijector, this is the
          (structure of) integer(s) value of `x_event_ndims` in the current context
          (for example, as passed to `experimental_batch_shape`). Otherwise, this
          argument should be `None`.
          Default value: `None`.
  
      Returns:
        new_batch_object: A batch-sliced `tfd.Distribution`.
      """
      if not isinstance(slices, collections.abc.Sequence):
          slices = (slices,)
      # We track the history of slice and copy(**param_overrides) in order to trace
      # back to the original object's source variables.
      #
      # NOTE: We must not modify `slice_overrides_seq`, as it could be an attribute
      # of `batch_object and this method should not modify `batch_object`.
      orig_batch_object, slice_overrides_seq = getattr(
          batch_object, PROVENANCE_ATTR, (batch_object, [])
      )
      slice_overrides_seq = slice_overrides_seq + [
          (slices, params_overrides)
      ]
      # Re-doing the full sequence of slice+copy override work here enables
      # gradients all the way back to the original batch_objectribution's arguments.
      batch_object = _apply_slice_sequence(
          orig_batch_object,
          slice_overrides_seq,
          bijector_x_event_ndims=bijector_x_event_ndims,
      )
      setattr(
          batch_object,
          PROVENANCE_ATTR,
          batch_object._no_dependency(
              (orig_batch_object, slice_overrides_seq)
          ),
      )  # pylint: disable=protected-access
      return batch_object
  
file_path: probability/tensorflow_probability/python/internal/slicing.py
imports: import collections
  import functools
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import batch_shape_lib
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 6 for calling a global function with example usage: batch_slice(batch_object, params_overrides, slices, bijector_x_event_ndims) and returns: batch_object