code: def test_external_source_callback_torch_stream():
      with torch.cuda.stream(torch.cuda.Stream()):
          for attempt in range(10):
              t0 = torch.tensor(
                  [attempt * 100 + 1.5], dtype=torch.float32
              ).cuda()
              increment = torch.tensor([10], dtype=torch.float32).cuda()
              pipe = Pipeline(1, 3, 0)
  
              def gen_batch():
                  nonlocal t0
                  t0 += increment
                  return [t0]
  
              pipe.set_outputs(fn.external_source(gen_batch))
              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_gpu.py
imports: from nose.plugins.attrib import attr
  from nvidia.dali.pipeline import Pipeline
  import nvidia.dali.fn
  from test_utils import check_output
  import torch
  from test_external_source_impl import use_torch
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: test_external_source_callback_torch_stream() and returns: list