code: def testSingletonDims(self):
      # A singleton dimension is a dimension i with shape[i] == 1. Such dimensions
      # can be collapsed and expanded using reshape without changing the
      # underlying data storage. If all non-singleton dimensions remain in
      # ascending order, the shuffled singletons will be transposed by a reshape,
      # saving a memory allocation & copy. Since this gets a special code-path in
      # transpose_op.cc, we test that the codepath is exercised and the results
      # are as expected; we do not test that we save the memory allocation and
      # copy here.
      for shape in [
          [2, 1, 2],
          [2, 1, 2, 1, 1, 2],
          [1, 2, 2, 1, 1, 1],
          [1, 1, 1, 2, 2, 2],
          [2, 2, 1, 1, 1],
      ]:
          with self.subTest(shape=shape):
              self._compare_cpu_gpu(
                  np.arange(np.prod(shape))
                  .reshape(shape)
                  .astype(np.float32)
              )
  
imports: import itertools
  import numpy
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradient_checker_v2
  from tensorflow.python.platform import test
label_desc: Use image node_id 28 for calling the TransposeTest obj's underlying member method code with example usage: obj.testSingletonDims() without return types