code: def _testimpl_jpeg_compression_distortion_sequence(
      batch_size, device, seq_len, quality
  ):
      @pipeline_def(batch_size=batch_size, num_threads=3, device_id=0)
      def jpeg_distortion_pipe(device="cpu", quality=None):
          iii = InputImagesIter(seq_len)
          inputs = fn.external_source(
              source=iii, layout="FHWC", batch=False
          )
          if device == "gpu":
              inputs = inputs.gpu()
          if quality is None:
              quality = fn.random.uniform(
                  range=[1, 99], dtype=types.INT32
              )
          tmp = fn.jpeg_compression_distortion(inputs, quality=quality)
          outs = []
          for i in range(seq_len):
              # First, slice of the distorted sequence
              outs.append(
                  fn.slice(tmp, axes=(0,), start=(i,), end=(i + 1,))
              )
              # Second, distorted slice of the input
              slice_in = fn.slice(
                  inputs, axes=(0,), start=(i,), end=(i + 1,)
              )
              outs.append(
                  fn.jpeg_compression_distortion(
                      slice_in, quality=quality
                  )
              )
          return tuple(outs)
  
      pipe = jpeg_distortion_pipe(device=device, quality=quality)
      pipe.build()
      for _ in range(3):
          out = pipe.run()
          nouts = len(out)
          assert nouts == (2 * seq_len)
          for i in range(0, nouts, 2):
              for s in range(batch_size):
                  out_data1 = as_array(out[i][s])
                  out_data2 = as_array(out[i + 1][s])
                  np.testing.assert_array_equal(out_data1, out_data2)
  
file_path: DALI/dali/test/python/operator_1/test_jpeg_compression_distortion.py
imports: from nvidia.dali import pipeline_def
  import nvidia.dali.fn
  import nvidia.dali.types
  from random import shuffle
  import numpy
  from test_utils import as_array
  import os
  import cv2
label_desc: Use image node_id 4 for calling a global function with example usage: _testimpl_jpeg_compression_distortion_sequence(batch_size, device, seq_len, quality) and returns: tuple