code: def _normalize_2D(image_data, norm, vmin, vmax, min_lum):
      """
      Take numpy 2D array of float or int-s and
      return 2D array of ints with the target range [0..255].
      Values outside the target range will be later clipped.
      """
      min_lum = max(0, min_lum)
      max_lum = 255 - min_lum
  
      vmin = float(
          vmin if vmin is not None else numpy.nanmin(image_data)
      )
      vmax = float(
          vmax if vmax is not None else numpy.nanmax(image_data)
      )
      if vmin > vmax:
          raise ValueError(
              "vmin value must be less then vmax value, was: {} > {}".format(
                  vmin, vmax
              )
          )
  
      normalize = as_boolean(norm, default=True)
  
      # Make a copy via `numpy.copy()` or via `arr.astype()`
      #   - prevent modification of the original image
      #   - work around read-only flag in the original image
  
      if normalize:
          if vmin == vmax:
              image_data = numpy.copy(image_data)
              image_data[True] = 127
          else:
              # float array for scaling
              if image_data.dtype.kind == "f":
                  image_data = numpy.copy(image_data)
              else:
                  image_data = image_data.astype(numpy.float32)
  
              image_data.clip(vmin, vmax, out=image_data)
  
              ratio = max_lum / (vmax - vmin)
              image_data -= vmin
              image_data *= ratio
              image_data += min_lum
      else:
          # no normalization
          image_data = numpy.copy(image_data)
          image_data.clip(min_lum, max_lum, out=image_data)
          vmin = float(numpy.nanmin(image_data))
          vmax = float(numpy.nanmax(image_data))
  
      return (image_data, vmin, vmax)
  
file_path: lets-plot/python-package/lets_plot/plot/geom_imshow_.py
imports: import base64
  import io
  from .core import aes
  from .geom import _geom
  from .scale import scale_gradientn
  from .scale import scale_grey
  from .util import as_boolean
  from .util import is_ndarray
label_desc: Use image node_id 3 for calling a global function with example usage: _normalize_2D(image_data, norm, vmin, vmax, min_lum) and returns: image_data,  vmin,  vmax