code: def feed_ndarray(
      dali_tensor: Union[
          TensorCPU, TensorGPU, TensorListCPU, TensorListGPU
      ],
      arr: torch.Tensor,
      cuda_stream: Union[torch.cuda.Stream, Any, None] = None,
  ) -> torch.Tensor:
      """
      Copy contents of DALI tensor to PyTorch's Tensor.
  
      Parameters
      ----------
      `dali_tensor` : nvidia.dali.backend.TensorCPU or nvidia.dali.backend.TensorGPU
                      Tensor from which to copy
      `arr` : torch.Tensor
              Destination of the copy
      `cuda_stream` : torch.cuda.Stream, cudaStream_t or any value that can be cast to cudaStream_t.
                      CUDA stream to be used for the copy
                      (if not provided, an internal user stream will be selected)
                      In most cases, using pytorch's current stream is expected (for example,
                      if we are copying to a tensor allocated with torch.zeros(...))
      """
      dali_type = to_torch_type[dali_tensor.dtype]
  
      assert dali_type == arr.dtype, (
          "The element type of DALI Tensor/TensorList"
          " doesn't match the element type of the target PyTorch Tensor: "
          "{} vs {}".format(dali_type, arr.dtype)
      )
      assert dali_tensor.shape() == list(
          arr.size()
      ), "Shapes do not match: DALI tensor has size {0}, but PyTorch Tensor has size {1}".format(
          dali_tensor.shape(), list(arr.size())
      )
      cuda_stream = types._raw_cuda_stream(cuda_stream)
  
      # turn raw int to a c void pointer
      c_type_pointer = ctypes.c_void_p(arr.data_ptr())
      if isinstance(dali_tensor, (TensorGPU, TensorListGPU)):
          stream = (
              None
              if cuda_stream is None
              else ctypes.c_void_p(cuda_stream)
          )
          dali_tensor.copy_to_external(
              c_type_pointer, stream, non_blocking=True
          )
      else:
          dali_tensor.copy_to_external(c_type_pointer)
      return arr
  
imports: import sys
  from typing import Union, Optional
  from typing import Any, Dict, List
  from nvidia.dali import internal
  from nvidia.dali import ops
  from nvidia.dali import types
  from nvidia.dali.backend import TensorCPU, TensorGPU, TensorListCPU, TensorListGPU
  from nvidia.dali.pipeline import Pipeline
  from nvidia.dali.plugin.base_iterator import _DaliBaseIterator
  from nvidia.dali.plugin.base_iterator import LastBatchPolicy
  import torch
  import torch.utils.dlpack
  import ctypes
  import numpy
  from .None import fn
  from nvidia.dali.plugin.pytorch._torch_function import TorchPythonFunction
label_desc: Use image node_id 1 for calling a global function with example usage: feed_ndarray(dali_tensor, arr, cuda_stream) and returns: arr