code: def test_image_decoder_lossless_jpeg(
      img_name, output_type, dtype, precision
  ):
      device_id = 0
      if not is_nvjpeg_lossless_supported(device_id=device_id):
          raise SkipTest(
              "NVJPEG lossless supported on SM60+ capable devices only"
          )
  
      data_dir = os.path.join(
          test_data_root, "db/single/jpeg_lossless/0"
      )
      ref_data_dir = os.path.join(
          test_data_root, "db/single/reference/jpeg_lossless"
      )
  
      @pipeline_def(batch_size=1, device_id=device_id, num_threads=1)
      def pipe(file):
          encoded, _ = fn.readers.file(files=[file])
          decoded = fn.experimental.decoders.image(
              encoded,
              device="mixed",
              dtype=dtype,
              output_type=output_type,
          )
          return decoded
  
      p = pipe(data_dir + f"/{img_name}.jpg")
      p.build()
      (out,) = p.run()
      result = np.array(out[0].as_cpu())
  
      ref = np.load(ref_data_dir + f"/{img_name}.npy")
      kwargs = {}
      np_dtype = types.to_numpy_type(dtype)
      max_val = (
          np_dtype(1.0)
          if dtype == types.FLOAT
          else np.iinfo(np_dtype).max
      )
      need_scaling = max_val != np_dtype(2**precision - 1)
      if need_scaling:
          multiplier = max_val / (2**precision - 1)
          ref = ref * multiplier
          if dtype != types.FLOAT:
              kwargs["atol"] = 0.5  # possible rounding error
      np.testing.assert_allclose(ref, result, **kwargs)
  
imports: import glob
  import math
  import numpy
  import nvidia.dali.backend
  import nvidia.dali.fn
  import nvidia.dali.types
  import os
  import random
  from nvidia.dali import pipeline_def
  from nose_utils import assert_raises
  from test_utils import compare_pipelines
  from test_utils import get_dali_extra_path
  from test_utils import to_array
  from test_utils import get_arch
  from nose2.tools import params
  from nose import SkipTest
label_desc: Use image node_id 27 for calling a global function with example usage: test_image_decoder_lossless_jpeg(img_name, output_type, dtype, precision) and returns: decoded