code: def wrap_image_array(arr):
      """Wrap a numpy array as a pyvista.ImageData.
  
      Parameters
      ----------
      arr : np.ndarray
          A numpy array of shape (X, Y, (3 or 4)) and dtype ``np.uint8``. For
          example, an array of shape ``(768, 1024, 3)``.
  
      Raises
      ------
      ValueError
          If the input array does not have 3 dimensions, the third dimension of
          the input array is not 3 or 4, or the input array is not of type
          ``np.uint8``.
  
      Returns
      -------
      pyvista.ImageData
          A PyVista ImageData object with the wrapped array data.
  
      """
      if arr.ndim != 3:
          raise ValueError("Expecting a X by Y by (3 or 4) array")
      if arr.shape[2] not in [3, 4]:
          raise ValueError("Expecting a X by Y by (3 or 4) array")
      if arr.dtype != np.uint8:
          raise ValueError("Expecting a np.uint8 array")
  
      img = _vtk.vtkImageData()
      img.SetDimensions(arr.shape[1], arr.shape[0], 1)
      wrap_img = pyvista.wrap(img)
      wrap_img.point_data["PNGImage"] = arr[::-1].reshape(
          -1, arr.shape[2]
      )
      return wrap_img
  
file_path: pyvista/pyvista/plotting/utilities/regression.py
imports: from typing import Optional, cast
  import numpy
  import pyvista
  from pyvista.core.utilities.arrays import point_array
  from pyvista.core.utilities.helpers import wrap
  from pyvista.plotting import _vtk
label_desc: Use image node_id 2 for calling a global function with example usage: wrap_image_array(arr) and returns: wrap_img