code: def _cupy_negative_strides_case(dtype, batch_size, steps):
      @pipeline_def(
          batch_size=batch_size, num_threads=4, device_id=0, seed=42
      )
      def baseline_pipeline():
          img, _ = fn.readers.file(
              name="Reader",
              file_root=images_dir,
              random_shuffle=True,
              seed=42,
          )
          img = fn.decoders.image(img, device="mixed")
          img = fn.cast(img, dtype=dtype)
          img = img[tuple(slice(None, None, step) for step in steps)]
          return img
  
      def flip_cupy(dlps):
          stream = current_dali_stream()
          cp_stream = cupy.cuda.ExternalStream(stream, device_id=0)
          with cp_stream:
              imgs = [cupy.from_dlpack(dlp) for dlp in dlps]
              imgs = [
                  img[tuple(slice(None, None, step) for step in steps)]
                  for img in imgs
              ]
              imgs = [img.toDlpack() for img in imgs]
          return imgs
  
      @pipeline_def(
          batch_size=batch_size, num_threads=4, device_id=0, seed=42
      )
      def pipeline():
          img, _ = fn.readers.file(
              name="Reader",
              file_root=images_dir,
              random_shuffle=True,
              seed=42,
          )
          img = fn.decoders.image(img, device="mixed")
          img = fn.cast(img, dtype=dtype)
          img = fn.dl_tensor_python_function(
              img,
              batch_processing=True,
              function=flip_cupy,
              synchronize_stream=False,
          )
          return img
  
      p = pipeline()
      p.build()
      baseline = baseline_pipeline()
      baseline.build()
  
      for _ in range(5):
          (batch,) = p.run()
          (baseline_batch,) = baseline.run()
          batch = [numpy.array(sample) for sample in batch.as_cpu()]
          baseline_batch = [
              numpy.array(sample) for sample in baseline_batch.as_cpu()
          ]
          assert len(batch) == len(baseline_batch) == batch_size
          for sample, baseline_sample in zip(batch, baseline_batch):
              numpy.testing.assert_equal(sample, baseline_sample)
  
imports: import numpy
  import nvidia.dali.ops
  import nvidia.dali.types
  import os
  import random
  from functools import partial
  from nvidia.dali.pipeline import Pipeline
  from nvidia.dali import fn, pipeline_def
  from nvidia.dali.python_function_plugin import current_dali_stream
label_desc: Use image node_id 40 for calling a global function with example usage: _cupy_negative_strides_case(dtype, batch_size, steps) and returns: img, imgs, img