code: def test_array_gen_cpy(self):
      xp = numpy if self.xp == "numpy" else cupy
      stream = None if not self.stream else cupy.cuda.Stream()
      width, height, depth = self.dimensions
      n_channel = self.n_channels
  
      dim = 3 if depth != 0 else 2 if height != 0 else 1
      shape = (
          (depth, height, n_channel * width)
          if dim == 3
          else (height, n_channel * width)
          if dim == 2
          else (n_channel * width,)
      )
  
      # generate input data and allocate output buffer
      if self.dtype in (numpy.float16, numpy.float32):
          arr = xp.random.random(shape).astype(self.dtype)
          kind = runtime.cudaChannelFormatKindFloat
      else:  # int
          arr = xp.random.randint(100, size=shape, dtype=self.dtype)
          if self.dtype in (numpy.int8, numpy.int16, numpy.int32):
              kind = runtime.cudaChannelFormatKindSigned
          else:
              kind = runtime.cudaChannelFormatKindUnsigned
  
      if self.c_contiguous:
          arr2 = xp.zeros_like(arr)
          assert arr.flags.c_contiguous
          assert arr2.flags.c_contiguous
      else:
          arr = arr[..., ::2]
          arr2 = xp.zeros_like(arr)
          width = arr.shape[-1] // n_channel
          assert not arr.flags.c_contiguous
          assert arr2.flags.c_contiguous
          assert arr.shape[-1] == n_channel * width
  
      # create a CUDA array
      ch_bits = [0, 0, 0, 0]
      for i in range(n_channel):
          ch_bits[i] = arr.dtype.itemsize * 8
      ch = ChannelFormatDescriptor(*ch_bits, kind)
      cu_arr = CUDAarray(ch, width, height, depth)
  
      # need to wait for the current stream to finish initialization
      if stream is not None:
          s = cupy.cuda.get_current_stream()
          e = s.record()
          stream.wait_event(e)
  
      # copy from input to CUDA array, and back to output
      cu_arr.copy_from(arr, stream)
      cu_arr.copy_to(arr2, stream)
  
      # check input and output are identical
      if stream is not None:
          stream.synchronize()
      assert (arr == arr2).all()
  
file_path: cupy/tests/cupy_tests/cuda_tests/test_texture.py
imports: import numpy
  import pytest
  import cupy
  from cupy import testing
  from cupy.cuda import runtime
  from cupy.cuda.texture import ChannelFormatDescriptor, CUDAarray, ResourceDescriptor, TextureDescriptor, TextureObject, SurfaceObject
label_desc: Use image node_id 1 for calling the TestCUDAarray obj's underlying member method code with example usage: obj.test_array_gen_cpy() without return types