code: def test_from_numpy(self, device) -> None:
      dtypes = [
          np.double,
          np.float64,
          np.float16,
          np.complex64,
          np.complex128,
          np.int64,
          np.int32,
          np.int16,
          np.int8,
          np.uint8,
          np.longlong,
          np.bool_,
      ]
      complex_dtypes = [
          np.complex64,
          np.complex128,
      ]
  
      for dtype in dtypes:
          array = np.array([1, 2, 3, 4], dtype=dtype)
          tensor_from_array = torch.from_numpy(array)
          # TODO: change to tensor equality check once HalfTensor
          # implements `==`
          for i in range(len(array)):
              self.assertEqual(tensor_from_array[i], array[i])
          # ufunc 'remainder' not supported for complex dtypes
          if dtype not in complex_dtypes:
              # This is a special test case for Windows
              # https://github.com/pytorch/pytorch/issues/22615
              array2 = array % 2
              tensor_from_array2 = torch.from_numpy(array2)
              for i in range(len(array2)):
                  self.assertEqual(tensor_from_array2[i], array2[i])
  
      # Test unsupported type
      array = np.array(["foo", "bar"], dtype=np.dtype(np.str_))
      with self.assertRaises(TypeError):
          tensor_from_array = torch.from_numpy(array)
  
      # check storage offset
      x = np.linspace(1, 125, 125)
      x.shape = (5, 5, 5)
      x = x[1]
      expected = torch.arange(1, 126, dtype=torch.float64).view(
          5, 5, 5
      )[1]
      self.assertEqual(torch.from_numpy(x), expected)
  
      # check noncontiguous
      x = np.linspace(1, 25, 25)
      x.shape = (5, 5)
      expected = torch.arange(1, 26, dtype=torch.float64).view(5, 5).t()
      self.assertEqual(torch.from_numpy(x.T), expected)
  
      # check noncontiguous with holes
      x = np.linspace(1, 125, 125)
      x.shape = (5, 5, 5)
      x = x[:, 1]
      expected = torch.arange(1, 126, dtype=torch.float64).view(
          5, 5, 5
      )[:, 1]
      self.assertEqual(torch.from_numpy(x), expected)
  
      # check zero dimensional
      x = np.zeros((0, 2))
      self.assertEqual(torch.from_numpy(x).shape, (0, 2))
      x = np.zeros((2, 0))
      self.assertEqual(torch.from_numpy(x).shape, (2, 0))
  
      # check ill-sized strides raise exception
      x = np.array([3.0, 5.0, 8.0])
      x.strides = (3,)
      self.assertRaises(ValueError, lambda: torch.from_numpy(x))
  
imports: import torch
  import numpy
  from itertools import product
  from torch.testing._internal.common_utils import skipIfTorchDynamo, TestCase, run_tests
  from torch.testing._internal.common_device_type import instantiate_device_type_tests, onlyCPU, dtypes, skipMeta
  from torch.testing._internal.common_dtype import all_types_and_complex_and
label_desc: Use image node_id 6 for calling the TestNumPyInterop obj's underlying member method code with example usage: obj.test_from_numpy(device) without return types