code: def test_to_array():
      def _to_array(mode, dtype):
          img = hopper(mode)
  
          # Resize to non-square
          img = img.crop((3, 0, 124, 127))
          assert img.size == (121, 127)
  
          np_img = numpy.array(img)
          _test_img_equals_nparray(img, np_img)
          assert np_img.dtype == dtype
  
      modes = [
          ("L", numpy.uint8),
          ("I", numpy.int32),
          ("F", numpy.float32),
          ("LA", numpy.uint8),
          ("RGB", numpy.uint8),
          ("RGBA", numpy.uint8),
          ("RGBX", numpy.uint8),
          ("CMYK", numpy.uint8),
          ("YCbCr", numpy.uint8),
          ("I;16", "<u2"),
          ("I;16B", ">u2"),
          ("I;16L", "<u2"),
          ("HSV", numpy.uint8),
      ]
  
      for mode in modes:
          _to_array(*mode)
  
file_path: pillow-simd/Tests/test_numpy.py
imports: import pytest
  from PIL import Image
  from .helper import assert_deep_equal, assert_image, hopper
label_desc: Use image node_id 8 for calling a global function with example usage: test_to_array() without return types