code: def test_parse_numpy_int(self, device):
      # Only concrete class can be given where "Type[number[_64Bit]]" is expected
      self.assertRaisesRegex(
          RuntimeError,
          "(Overflow|an integer is required)",
          lambda: torch.mean(torch.randn(1, 1), np.uint64(-1)),
      )  # type: ignore[call-overload]
      # https://github.com/pytorch/pytorch/issues/29252
      for nptype in [np.int16, np.int8, np.uint8, np.int32, np.int64]:
          scalar = 3
          np_arr = np.array([scalar], dtype=nptype)
          np_val = np_arr[0]
  
          # np integral type can be treated as a python int in native functions with
          # int parameters:
          self.assertEqual(
              torch.ones(5).diag(scalar), torch.ones(5).diag(np_val)
          )
          self.assertEqual(
              torch.ones([2, 2, 2, 2]).mean(scalar),
              torch.ones([2, 2, 2, 2]).mean(np_val),
          )
  
          # numpy integral type parses like a python int in custom python bindings:
          self.assertEqual(torch.Storage(np_val).size(), scalar)  # type: ignore[attr-defined]
  
          tensor = torch.tensor([2], dtype=torch.int)
          tensor[0] = np_val
          self.assertEqual(tensor[0], np_val)
  
          # Original reported issue, np integral type parses to the correct
          # PyTorch integral type when passed for a `Scalar` parameter in
          # arithmetic operations:
          t = torch.from_numpy(np_arr)
          self.assertEqual((t + np_val).dtype, t.dtype)
          self.assertEqual((np_val + t).dtype, t.dtype)
  
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 14 for calling the TestNumPyInterop obj's underlying member method code with example usage: obj.test_parse_numpy_int(device) without return types