code: def sample_to_numpy(
      sample, error_str="Unsupported callback return type. Got: `{}`."
  ):
      import_numpy()
      assert_cpu_sample_data_type(sample, error_str)
      if isinstance(sample, np.ndarray):
          return sample
      if types._is_mxnet_array(sample):
          if sample.context.device_type != "cpu":
              raise TypeError(
                  "Unsupported callback return type. "
                  "GPU tensors are not supported. Got an MXNet GPU tensor."
              )
          return sample.asnumpy()
      if types._is_torch_tensor(sample):
          if sample.device.type != "cpu":
              raise TypeError(
                  "Unsupported callback return type. "
                  "GPU tensors are not supported. Got a PyTorch GPU tensor."
              )
          return sample.numpy()
      elif isinstance(sample, tensors.TensorCPU):
          return np.array(sample)
      raise TypeError(error_str.format(type(sample)))
  
imports: from enum import Enum
  from nvidia.dali import types
  from nvidia.dali import tensors
  import inspect
  import functools
label_desc: Use image node_id 4 for calling a global function with example usage: sample_to_numpy(sample, error_str) and returns: sample, sample, sample, np