code: def autoscale_colors_for_png(arr, vmin=None, vmax=None):
      """Adjust an array to prepare it for saving to an image.
  
      Re-scale numbers in the input array to go from 0 to 255 to adapt them for a
      PNG image.
  
      Args:
        arr: numpy array. Should be 2-dimensional or 3-dimensional where the third
          dimension has 3 channels.
        vmin: number (float or int). Minimum data value, which will correspond to
          black in greyscale or lack of each color in RGB images. Default None takes
          the minimum of the data from arr.
        vmax: number (float or int). Maximum data value, which will correspond to
          white in greyscale or full presence of each color in RGB images. Default
          None takes the max of the data from arr.
  
      Returns:
        (modified numpy array, image_mode)
      """
      image_mode = _get_image_type_from_array(arr)
  
      if vmin is None:
          vmin = np.min(arr)
      if vmax is None:
          vmax = np.max(arr)
  
      # In cases where all elements are the same, fix the vmax so that even though
      # the whole image will be black, the user can at least see the shape
      if vmin == vmax:
          vmax = vmin + 1
  
      scaled = scale_colors_for_png(arr, vmin=vmin, vmax=vmax)
      return scaled, image_mode
  
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 7 for calling a global function with example usage: autoscale_colors_for_png(arr, vmin, vmax) and returns: scaled,  image_mode