class_docstr: Tests correctness of the `Transpose` bijector.
class_docstr_tok: ["Tests","correctness","of","the","`","Transpose","`","bijector","."]
code: def testEventShapes(self):
      shape_static = [5, 4, 3, 2]
      shape_dynamic = tf1.placeholder_with_default(
          tf.constant(shape_static), shape=None
      )
  
      def make_bijector(perm=None, rightmost_transposed_ndims=None):
          if perm is not None:
              perm = tf.convert_to_tensor(value=perm)
              if not self.is_static:
                  perm = tf1.placeholder_with_default(
                      perm, shape=perm.shape
                  )
          return transpose.Transpose(
              perm,
              rightmost_transposed_ndims=rightmost_transposed_ndims,
          )
  
      for is_shape_static, shape, shape_t in [
          (
              True,
              tf.zeros(shape_static).shape,
              tf.constant(shape_static),
          ),
          (False, tf.zeros(shape_dynamic).shape, shape_dynamic),
      ]:
          # pylint: disable=cell-var-from-loop
          def event_shape(b, direction):
              shape_fn = getattr(b, "{}_event_shape".format(direction))
              if (
                  is_shape_static and self.is_static
              ) or tf.executing_eagerly():
                  result = shape_fn(shape)
                  self.assertTrue(
                      tensorshape_util.is_fully_defined(result)
                  )
                  return result
              if is_shape_static:
                  self.assertEqual(len(shape), shape_fn(shape).ndims)
              else:
                  self.assertIsNone(shape_fn(shape).ndims)
              shape_tensor_fn = getattr(
                  b, "{}_event_shape_tensor".format(direction)
              )
              return self.evaluate(shape_tensor_fn(shape_t))
  
          # pylint: enable=cell-var-from-loop
  
          self.assertAllEqual(
              (5, 3, 4, 2),
              event_shape(make_bijector([1, 0, 2]), "forward"),
          )
          self.assertAllEqual(
              (5, 2, 4, 3),
              event_shape(make_bijector([2, 0, 1]), "forward"),
          )
          self.assertAllEqual(
              (5, 4, 2, 3),
              event_shape(
                  make_bijector(rightmost_transposed_ndims=2), "forward"
              ),
          )
          self.assertAllEqual(
              (5, 2, 3, 4),
              event_shape(
                  make_bijector(rightmost_transposed_ndims=3), "forward"
              ),
          )
          self.assertAllEqual(
              (5, 3, 4, 2),
              event_shape(make_bijector([1, 0, 2]), "inverse"),
          )
          self.assertAllEqual(
              (5, 3, 2, 4),
              event_shape(make_bijector([2, 0, 1]), "inverse"),
          )
          self.assertAllEqual(
              (5, 4, 2, 3),
              event_shape(
                  make_bijector(rightmost_transposed_ndims=2), "inverse"
              ),
          )
          self.assertAllEqual(
              (5, 2, 3, 4),
              event_shape(
                  make_bijector(rightmost_transposed_ndims=3), "inverse"
              ),
          )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.bijectors import transpose
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 6 for calling the _TransposeBijectorTest obj's underlying member method code with example usage: obj.testEventShapes() and returns: transpose, self, result