code: def test_jpeg_quality():
      """Compare mean abs error between different encoding quality settings. Higher quality value should result
      in a smaller error"""
      size = (300, 200, 3)
      expected_image = np.random.randint(
          0, 255, size=size, dtype=np.uint8
      )
  
      errors = dict()
      for quality in [10, 99]:
          codec = CompressedImageCodec("jpeg", quality=quality)
          field = UnischemaField(
              name="field_image",
              numpy_dtype=np.uint8,
              shape=size,
              codec=codec,
              nullable=False,
          )
          actual_image = codec.decode(
              field, codec.encode(field, expected_image)
          )
          errors[quality] = np.mean(
              np.abs(
                  expected_image.astype(np.float)
                  - actual_image.astype(np.float)
              )
          )
  
      assert errors[10] > errors[99]
  
file_path: petastorm/petastorm/tests/test_codec_compressed_image.py
imports: import io
  import numpy
  import pytest
  from PIL import Image
  from petastorm.codecs import CompressedImageCodec
  from petastorm.unischema import UnischemaField
label_desc: Use image node_id 3 for calling a global function with example usage: test_jpeg_quality() without return types