code: def _clip_image(
      image: "npt.NDArray[Any]", clamp: bool
  ) -> "npt.NDArray[Any]":
      data = image
      if issubclass(image.dtype.type, np.floating):
          if clamp:
              data = np.clip(image, 0, 1.0)
          else:
              if np.amin(image) < 0.0 or np.amax(image) > 1.0:
                  raise RuntimeError(
                      "Data is outside [0.0, 1.0] and clamp is not set."
                  )
          data = data * 255
      else:
          if clamp:
              data = np.clip(image, 0, 255)
          else:
              if np.amin(image) < 0 or np.amax(image) > 255:
                  raise RuntimeError(
                      "Data is outside [0, 255] and clamp is not set."
                  )
      return data
  
imports: import base64
  import io
  import mimetypes
  import re
  from enum import IntEnum
  from typing import TYPE_CHECKING, List, Optional, Sequence, Union, cast
  from urllib.parse import urlparse
  import numpy
  from PIL import GifImagePlugin, Image, ImageFile
  from typing_extensions import Final, Literal, TypeAlias
  from streamlit import runtime
  from streamlit.errors import StreamlitAPIException
  from streamlit.logger import get_logger
  from streamlit.proto.Image_pb2 import ImageList
  from streamlit.runtime import caching
  from streamlit.runtime.metrics_util import gather_metrics
label_desc: Use image node_id 11 for calling a global function with example usage: _clip_image(image, clamp) and returns: data