code: def test_invalid_image_size():
      """Codec can encode only (H, W) and (H, W, 3) images"""
      codec = CompressedImageCodec("png")
  
      field = UnischemaField(
          name="field_image",
          numpy_dtype=np.uint8,
          shape=(10, 10, 3),
          codec=codec,
          nullable=False,
      )
  
      with pytest.raises(ValueError):
          codec.encode(field, np.zeros((10,), dtype=np.uint8))
  
      with pytest.raises(ValueError):
          codec.encode(field, np.zeros((10, 10, 2), dtype=np.uint8))
  
      with pytest.raises(ValueError):
          codec.encode(
              field, np.zeros((10, 10, 10, 10), dtype=np.uint8)
          )
  
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 7 for calling a global function with example usage: test_invalid_image_size() without return types