code: def test_fromarray():
      class Wrapper:
          """Class with API matching Image.fromarray"""
  
          def __init__(self, img, arr_params):
              self.img = img
              self.__array_interface__ = arr_params
  
          def tobytes(self):
              return self.img.tobytes()
  
      def test(mode):
          i = im.convert(mode)
          a = numpy.array(i)
          # Make wrapper instance for image, new array interface
          wrapped = Wrapper(
              i,
              {
                  "shape": a.shape,
                  "typestr": a.dtype.str,
                  "version": 3,
                  "data": a.data,
                  "strides": 1,  # pretend it's non-contiguous
              },
          )
          out = Image.fromarray(wrapped)
          return (
              out.mode,
              out.size,
              list(i.getdata()) == list(out.getdata()),
          )
  
      # assert test("1") == ("1", (128, 100), True)
      assert test("L") == ("L", (128, 100), True)
      assert test("I") == ("I", (128, 100), True)
      assert test("F") == ("F", (128, 100), True)
      assert test("LA") == ("LA", (128, 100), True)
      assert test("RGB") == ("RGB", (128, 100), True)
      assert test("RGBA") == ("RGBA", (128, 100), True)
      assert test("RGBX") == ("RGBA", (128, 100), True)
  
      # Test mode is None with no "typestr" in the array interface
      with pytest.raises(TypeError):
          wrapped = Wrapper(test("L"), {"shape": (100, 128)})
          Image.fromarray(wrapped)
  
imports: import pytest
  from PIL import Image
  from .helper import hopper
label_desc: Use image node_id 2 for calling a global function with example usage: test_fromarray() and returns: out,  out,  unknown, self