code: def wrap_ndarray(cls, arr: cupy.ndarray | numpy.ndarray, constructor):
      """Wrap an ndarray in a proxy type
  
      Parameters
      ----------
      cls
          Proxy type for ndarray
      arr
          Concrete result ndarray (cupy or numpy)
      constructor
          Function that was called to construct the concrete array, used
          to check against a denylist to avoid unwrapping.
  
      Returns
      -------
      The scalar .item() wrapped in its numpy dtype if arr is a
      zero-dimensional cupy array (and wasn't just constructed as such),
      a new proxy type otherwise.
  
      Notes
      -----
      Axis-reducing operations in numpy return scalar objects but
      zero-dimensional arrays in cupy. This confuses downstream
      libraries when they get a fast (device-based) zero-dim array when
      they were expecting a scalar. To avoid this, if the provided array
      is a cupy array, and its shape is zero, unwrap it.
      """
      if (
          isinstance(arr, cupy.ndarray)
          and arr.shape == ()
          and constructor not in _CONSTRUCTORS
      ):
          return arr.dtype.type(arr.item())
      else:
          # Note, this super call means that the constructed ndarray
          # class cannot be subclassed (because then super(cls,
          # cls)._fsproxy_wrap produces an infinite loop). Really this
          # should be super(ndarray, cls), but we don't have access to
          # the ndarray type until after we need to pass this function
          # in. So it works for now since without subclassing,
          # super(ndarray, cls) == super(ndarray, ndarray) == super(cls,
          # cls)
          return super(cls, cls)._fsproxy_wrap(arr, constructor)
  
imports: from __future__ import annotations
  import cupy
  import cupy._core.flags
  import numpy
  import numpy.core.multiarray
  from ..fast_slow_proxy import make_final_proxy_type, make_intermediate_proxy_type
  from .common import array_method, arrow_array_method, cuda_array_interface, custom_iter
label_desc: Use image node_id 1 for calling a global function with example usage: wrap_ndarray(cls, arr, constructor) and returns: arr, super