code: def np_unary_ufunc_integer_promotion_wrapper(fn):
      # Wrapper that passes PyTorch's default scalar
      #   type as an argument to the wrapped NumPy
      #   unary ufunc when given an integer input.
      #   This mimicks PyTorch's integer->floating point
      #   type promotion.
      #
      # This is necessary when NumPy promotes
      #   integer types to double, since PyTorch promotes
      #   integer types to the default scalar type.
  
      # Helper to determine if promotion is needed
      def is_integral(dtype):
          return dtype in [
              np.bool_,
              bool,
              np.uint8,
              np.int8,
              np.int16,
              np.int32,
              np.int64,
          ]
  
      @wraps(fn)
      def wrapped_fn(x):
          # As the default dtype can change, acquire it when function is called.
          # NOTE: Promotion in PyTorch is from integer types to the default dtype
          np_dtype = torch_to_numpy_dtype_dict[
              torch.get_default_dtype()
          ]
  
          if is_integral(x.dtype):
              return fn(x.astype(np_dtype))
          return fn(x)
  
      return wrapped_fn
  
file_path: pytorch/torch/testing/_internal/opinfo/utils.py
imports: import collections
  import warnings
  from functools import partial, wraps
  from typing import Sequence
  import numpy
  import torch
  from torch.testing._internal.common_cuda import TEST_CUDA
  from torch.testing._internal.common_dtype import _dispatch_dtypes, all_types, all_types_and, all_types_and_complex, all_types_and_complex_and, all_types_and_half, complex_types, floating_and_complex_types, floating_and_complex_types_and, floating_types, floating_types_and, floating_types_and_half, integral_types, integral_types_and
  from torch.testing._internal.common_utils import torch_to_numpy_dtype_dict
label_desc: Use image node_id 5 for calling a global function with example usage: np_unary_ufunc_integer_promotion_wrapper(fn) and returns: wrapped_fn, unknown, fn, fn