code: def _get_image_type_from_array(arr):
      """Find image type based on array dimensions.
  
      Raises error on invalid image dimensions.
      Args:
        arr: numpy array. Input array.
  
      Returns:
        str. "RGB" or "L", meant for PIL.Image.fromarray.
      """
      if len(arr.shape) == 3 and arr.shape[2] == 3:
          # 8-bit x 3 colors
          return "RGB"
      elif len(arr.shape) == 2:
          # 8-bit, gray-scale
          return "L"
      else:
          raise ValueError(
              "Input array must have either 2 dimensions or 3 dimensions where the "
              "third dimension has 3 channels. i.e. arr.shape is (x,y) or (x,y,3). "
              "Found shape {}.".format(arr.shape)
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import enum
  import math
  from typing import List, NamedTuple, Tuple
  from etils import epath
  from IPython import display
  import numpy
  from PIL import Image
  from PIL import ImageDraw
  from third_party.nucleus.protos import variants_pb2
label_desc: Use image node_id 6 for calling a global function with example usage: _get_image_type_from_array(arr) and returns: str, str