code: def _get_numpy_as_image(array):
      array = array.copy()  # prevent original array from modifying
  
      array *= 255
      shape = array.shape
      if len(shape) == 2:
          return _get_pil_image_data(
              Image.fromarray(array.astype(numpy.uint8))
          )
      if len(shape) == 3:
          if shape[2] == 1:
              array2d = numpy.array(
                  [[col[0] for col in row] for row in array]
              )
              return _get_pil_image_data(
                  Image.fromarray(array2d.astype(numpy.uint8))
              )
          if shape[2] in (3, 4):
              return _get_pil_image_data(
                  Image.fromarray(array.astype(numpy.uint8))
              )
      raise ValueError(
          "Incorrect size of numpy.ndarray. Should be 2-dimensional or"
          " 3-dimensional with 3rd dimension of size 1, 3 or 4."
      )
  
file_path: neptune-client/src/neptune/legacy/internal/utils/image.py
imports: import io
  import os
  import numpy
  import six
  from PIL import Image
  from neptune.legacy.exceptions import FileNotFound, InvalidChannelValue
label_desc: Use image node_id 4 for calling a global function with example usage: _get_numpy_as_image(array) and returns: _get_pil_image_data, _get_pil_image_data, _get_pil_image_data