code: def _test_slicing(self, data, bijector_name, bijector, event_dim):
      batch_shape = bijector.experimental_batch_shape()
      slices = data.draw(tfp_hps.valid_slices(batch_shape))
      slice_str = "bijector[{}]".format(
          ", ".join(tfp_hps.stringify_slices(slices))
      )
      # Make sure the slice string appears in Hypothesis' attempted example log
      hp.note("Using slice " + slice_str)
      if not slices:  # Nothing further to check.
          return
  
      sliced_bijector = bijector[slices]
  
      # This should have no effect on a trivially instantiable bijector.
      if bijector_name in bhps.trivially_instantiable_bijectors():
          self.assertAllEqual(
              bijector.experimental_batch_shape(),
              sliced_bijector.experimental_batch_shape(),
          )
          return
  
      sliced_zeros = np.zeros(batch_shape)[slices]
      hp.note("Using sliced bijector {}.".format(sliced_bijector))
      # Check that slicing modifies batch shape as expected.
      self.assertAllEqual(
          sliced_zeros.shape, sliced_bijector.experimental_batch_shape()
      )
  
      if not sliced_zeros.size:
          # TODO(b/128924708): Fix bijectors that fail on degenerate empty
          #     shapes.
          return
  
      xs = self._draw_domain_tensor(bijector, data, event_dim)
      with tfp_hps.no_tf_rank_errors():
          forward = self.evaluate(bijector.forward(xs))
          sliced_bijector_forward = self.evaluate(
              sliced_bijector.forward(xs)
          )
  
      # Come up with the slices for samples (which must also include event dims).
      forward_slices = (
          tuple(slices)
          if isinstance(slices, collections.abc.Sequence)
          else (slices,)
      )
      if Ellipsis not in forward_slices:
          forward_slices += (Ellipsis,)
      forward_slices += tuple(
          [slice(None)] * bijector.inverse_min_event_ndims
      )
  
      sliced_forward = forward[forward_slices]
  
      # Check that slicing the bijector computation has the same shape as
      # using the sliced bijector and computing results.
      self.assertAllEqual(
          sliced_forward.shape, sliced_bijector_forward.shape
      )
      self.assertAllClose(
          sliced_forward,
          sliced_bijector_forward,
          atol=SLICING_ATOL[bijector_name],
          rtol=SLICING_RTOL[bijector_name],
      )
  
imports: import collections
  import functools
  from absl.testing import parameterized
  import hypothesis
  from hypothesis import strategies
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python import bijectors
  from tensorflow_probability.python import util
  from tensorflow_probability.python.bijectors import hypothesis_testlib
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.internal import auto_composite_tensor
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling the BijectorSlicingTest obj's underlying member method code with example usage: obj._test_slicing(data, bijector_name, bijector, event_dim) without return types