code: def _slice_single_param(
      param, param_event_ndims, slices, batch_shape
  ):
      """Slices into the batch shape of a single parameter.
  
      Args:
        param: The original parameter to slice; either a `Tensor` or an object
          with batch shape (Distribution, Bijector, etc).
        param_event_ndims: `int` event rank of this parameter. For non-Tensor
          parameters, this is the number of this param's batch dimensions used by
          an event of the parent object.
        slices: iterable of slices received by `__getitem__`.
        batch_shape: The parameterized object's batch shape `Tensor`.
  
      Returns:
        new_param: Instance of the same type as `param`, batch-sliced according to
          `slices`.
      """
      # Broadcast the parmameter to have full batch rank.
      param = batch_shape_lib.broadcast_parameter_with_batch_shape(
          param, param_event_ndims, ps.ones_like(batch_shape)
      )
      param_batch_shape = batch_shape_lib.get_batch_shape_tensor_part(
          param, param_event_ndims
      )
      # At this point the param should have full batch rank, *unless* it's an
      # atomic object like `tfb.Identity()` incapable of having any batch rank.
      if (
          tf.get_static_value(ps.rank_from_shape(batch_shape)) != 0
          and tf.get_static_value(ps.rank_from_shape(param_batch_shape))
          == 0
      ):
          return param
      param_slices = _sanitize_slices(
          slices,
          intended_shape=batch_shape,
          deficient_shape=param_batch_shape,
      )
  
      # Bijectors (which have no fixed batch shape) handle `param_event_ndims` in
      # the recursive call.
      if hasattr(param, "forward_min_event_ndims"):
          return batch_slice(
              param,
              params_overrides={},
              slices=tuple(param_slices),
              bijector_x_event_ndims=param_event_ndims,
          )
  
      # Otherwise, extend `param_slices` (which represents slicing into the
      # parameter's batch shape) with the parameter's event ndims. For example, if
      # `params_event_ndims == 1`, then `[i, ..., j]` would become `[i, ..., j, :]`.
      if param_event_ndims > 0:
          if Ellipsis not in [
              slc for slc in slices if not tf.is_tensor(slc)
          ]:
              param_slices.append(Ellipsis)
          param_slices += [slice(None)] * param_event_ndims
      return param.__getitem__(tuple(param_slices))
  
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 2 for calling a global function with example usage: _slice_single_param(param, param_event_ndims, slices, batch_shape) and returns: param, param, batch_slice