code: def prepare_thumbnail(
      image: t.Union[pilimage.Image, np.ndarray],
      size: t.Optional[t.Tuple[int, int]] = None,
      copy_image: bool = True,
  ) -> str:
      """Prepare html image tag with the provided image.
  
      Parameters
      ----------
      image : Union[PIL.Image.Image, numpy.ndarray]
          image to use
      size : Optional[Tuple[int, int]], default None
          size to which image should be rescaled
      copy_image : bool, default True
          to rescale the image to the provided size this function uses
          `PIL.Image.Image.thumbnail` method that modified image instance
          in-place. If `copy_image` is set to True image will be copied
          before rescaling.
  
      Returns
      -------
      str : html '<img>' tag with embedded image
      """
      if size is not None:
          image = ensure_image(image, copy=copy_image)
          # First define the correct size with respect to the original aspect ratio
          width_factor = size[0] / image.size[0]
          height_factor = size[1] / image.size[1]
          # Takes the minimum factor in order for the image to not exceed the size in either width or height
          factor = min(width_factor, height_factor)
          size = (
              int(image.size[0] * factor),
              int(image.size[1] * factor),
          )
          # Resize the image by Image.LANCZOS
          image = image.resize(size, pilimage.LANCZOS)
      else:
          image = ensure_image(image, copy=False)
  
      img_bytes = io.BytesIO()
      image.save(img_bytes, optimize=True, quality=60, format="jpeg")
      img_bytes.seek(0)
      tag = imagetag(img_bytes.read())
      img_bytes.close()
      return tag
  
imports: import io
  import typing
  from numbers import Number
  from pathlib import Path
  import cv2
  import numpy
  import PIL.Image
  import PIL.ImageDraw
  import PIL.ImageOps
  import plotly.graph_objects
  from PIL import ImageColor, ImageFont
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.utils.html import imagetag
  from deepchecks.vision.vision_data import TaskType
  from deepchecks.vision.vision_data.utils import LabelMap
  from .detection_formatters import convert_bbox
label_desc: Use image node_id 6 for calling a global function with example usage: prepare_thumbnail(image, size, copy_image) and returns: tag