code: def test_jpeg_compress(art_warning, image_batch, channels_first):
      try:
          test_input, test_output = image_batch
          # Run only for grayscale [1] and RGB [3] data because testing `_compress` which is applied internally only to
          # either grayscale or RGB data.
          if test_input.shape[-1] in [1, 3]:
              jpeg_compression = JpegCompression(clip_values=(0, 255))
  
              image_mode = "RGB" if test_input.shape[-1] == 3 else "L"
              test_single_input = np.squeeze(test_input[0]).astype(
                  np.uint8
              )
              test_single_output = np.squeeze(test_output[0]).astype(
                  np.uint8
              )
  
              assert_array_equal(
                  jpeg_compression._compress(
                      test_single_input, image_mode
                  ),
                  test_single_output,
              )
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/defences/preprocessor/test_jpeg_compression.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from art.config import ART_NUMPY_DTYPE
  from art.defences.preprocessor import JpegCompression
  from tests.utils import ARTTestException
label_desc: Use image node_id 5 for calling a global function with example usage: test_jpeg_compress(art_warning, image_batch, channels_first) without return types