code: def _test_external_source_callback_torch_stream(
      src_device, gen_device
  ):
      with torch.cuda.stream(torch.cuda.Stream()):
          for attempt in range(10):
              t0 = torch.tensor(
                  [attempt * 100 + 1.5],
                  dtype=torch.float32,
                  device=gen_device,
              )
              increment = torch.tensor(
                  [10], dtype=torch.float32, device=gen_device
              )
              pipe = Pipeline(1, 3, 0)
  
              def gen_batch():
                  nonlocal t0
                  t0 += increment
                  return [to_dlpack(t0)]
  
              pipe.set_outputs(
                  fn.external_source(
                      source=gen_batch,
                      device=src_device,
                      cuda_stream=torch.cuda.current_stream(),
                  )
              )
              pipe.build()
  
              for i in range(10):
                  check_output(
                      pipe.run(),
                      [
                          np.array(
                              [attempt * 100 + (i + 1) * 10 + 1.5],
                              dtype=np.float32,
                          )
                      ],
                  )
  
file_path: DALI/dali/test/python/test_external_source_pytorch_dlpack.py
imports: import numpy
  import nvidia.dali.fn
  import nvidia.dali.ops
  import torch
  from nvidia.dali.backend_impl import *
  from nvidia.dali import Pipeline
  from torch.utils.dlpack import to_dlpack, from_dlpack
  from test_utils import check_output
label_desc: Use image node_id 5 for calling a global function with example usage: _test_external_source_callback_torch_stream(src_device, gen_device) and returns: list