code: def test_types(self, device):
      bits_types = [
          torch.bits1x8,
          torch.bits2x4,
          torch.bits4x2,
          torch.bits8,
          torch.bits16,
      ]
      for bits_type in bits_types:
          _ = torch.zeros(20, dtype=torch.int32, device=device).view(
              bits_type
          )
          _ = torch.empty(20, dtype=bits_type, device=device)
          x = torch.randint(
              100, (20, 20), dtype=torch.int8, device=device
          ).view(bits_type)
          y = x.t().contiguous()
          view_type = (
              torch.int8 if x.element_size() == 1 else torch.int16
          )
          self.assertEqual(x.t().view(view_type), y.view(view_type))
          y = x.t().clone()
          self.assertEqual(x.t().view(view_type), y.view(view_type))
  
file_path: pytorch/test/quantization/core/experimental/test_bits.py
imports: import torch
  from torch.testing._internal.common_device_type import instantiate_device_type_tests
  from torch.testing._internal.common_utils import run_tests, TestCase, skipIfRocm
  from torch.utils._mode_utils import no_dispatch
  from torch.utils._pytree import tree_map
  import itertools
label_desc: Use image node_id 1 for calling the TestBits obj's underlying member method code with example usage: obj.test_types(device) without return types