code: def np_to_array(nparray, order, allowSurfaceBind=False):  # noqa: N803
      case = order in ["C", "F"]
      if not case:
          raise LogicError("order must be either F or C")
  
      dimension = len(nparray.shape)
      if dimension == 2:
          if order == "C":
              stride = 0
          if order == "F":
              stride = -1
          h, w = nparray.shape
          d = 1
          if allowSurfaceBind:
              descrArr = ArrayDescriptor3D()
              descrArr.width = w
              descrArr.height = h
              descrArr.depth = d
          else:
              descrArr = ArrayDescriptor()
              descrArr.width = w
              descrArr.height = h
      elif dimension == 3:
          if order == "C":
              stride = 1
          if order == "F":
              stride = 1
          d, h, w = nparray.shape
          descrArr = ArrayDescriptor3D()
          descrArr.width = w
          descrArr.height = h
          descrArr.depth = d
      else:
          raise LogicError(
              "CUDArrays dimensions 2 or 3 supported in CUDA at the moment ... "
          )
  
      if nparray.dtype == np.complex64:
          descrArr.format = (
              array_format.SIGNED_INT32
          )  # Reading data as int2 (hi=re,lo=im) structure
          descrArr.num_channels = 2
      elif nparray.dtype == np.float64:
          descrArr.format = (
              array_format.SIGNED_INT32
          )  # Reading data as int2 (hi,lo) structure
          descrArr.num_channels = 2
      elif nparray.dtype == np.complex128:
          descrArr.format = (
              array_format.SIGNED_INT32
          )  # Reading data as int4 (re=(hi,lo),im=(hi,lo)) structure
          descrArr.num_channels = 4
      else:
          descrArr.format = dtype_to_array_format(nparray.dtype)
          descrArr.num_channels = 1
  
      if allowSurfaceBind:
          if dimension == 2:
              descrArr.flags |= array3d_flags.ARRAY3D_LAYERED
          descrArr.flags |= array3d_flags.SURFACE_LDST
  
      cudaArray = Array(descrArr)
      if allowSurfaceBind or dimension == 3:
          copy3D = Memcpy3D()
          copy3D.set_src_host(nparray)
          copy3D.set_dst_array(cudaArray)
          copy3D.width_in_bytes = copy3D.src_pitch = nparray.strides[
              stride
          ]
          copy3D.src_height = copy3D.height = h
          copy3D.depth = d
          copy3D()
          return cudaArray
      else:
          copy2D = Memcpy2D()
          copy2D.set_src_host(nparray)
          copy2D.set_dst_array(cudaArray)
          copy2D.width_in_bytes = copy2D.src_pitch = nparray.strides[
              stride
          ]
          copy2D.src_height = copy2D.height = h
          copy2D(aligned=True)
          return cudaArray
  
imports: import os
  import numpy
label_desc: Use image node_id 17 for calling a global function with example usage: np_to_array(nparray, order, allowSurfaceBind) and returns: cudaArray, cudaArray