code: def test_rearrange_consistency(self) -> None:
      shape = [1, 2, 3, 5, 7, 11]
      x = torch.arange(int(np.prod(shape, dtype=int))).reshape(shape)
      for pattern in [
          "a b c d e f -> a b c d e f",
          "b a c d e f -> a b d e f c",
          "a b c d e f -> f e d c b a",
          "a b c d e f -> (f e) d (c b a)",
          "a b c d e f -> (f e d c b a)",
      ]:
          result = rearrange(x, pattern)
          self.assertEqual(len(np.setdiff1d(x, result)), 0)
          self.assertIs(result.dtype, x.dtype)
  
      result = rearrange(x, "a b c d e f -> a (b) (c d e) f")
      torch.testing.assert_close(x.flatten(), result.flatten())
  
      result = rearrange(
          x, "a aa aa1 a1a1 aaaa a11 -> a aa aa1 a1a1 aaaa a11"
      )
      torch.testing.assert_close(x, result)
  
      result1 = rearrange(x, "a b c d e f -> f e d c b a")
      result2 = rearrange(x, "f e d c b a -> a b c d e f")
      torch.testing.assert_close(result1, result2)
  
      result = rearrange(
          rearrange(x, "a b c d e f -> (f d) c (e b) a"),
          "(f d) c (e b) a -> a b c d e f",
          b=2,
          d=5,
      )
      torch.testing.assert_close(x, result)
  
      sizes = dict(zip("abcdef", shape))
      temp = rearrange(x, "a b c d e f -> (f d) c (e b) a", **sizes)
      result = rearrange(
          temp, "(f d) c (e b) a -> a b c d e f", **sizes
      )
      torch.testing.assert_close(x, result)
  
      x2 = torch.arange(2 * 3 * 4).reshape([2, 3, 4])
      result = rearrange(x2, "a b c -> b c a")
      self.assertEqual(x2[1, 2, 3], result[2, 3, 1])
      self.assertEqual(x2[0, 1, 2], result[1, 2, 0])
  
file_path: pytorch/test/functorch/test_rearrange.py
imports: from typing import List, Tuple
  import numpy
  import torch
  from functorch.einops import rearrange
  from torch.testing._internal.common_utils import TestCase, run_tests
label_desc: Use image node_id 3 for calling the TestRearrange obj's underlying member method code with example usage: obj.test_rearrange_consistency() without return types