code: def to_blob(blob: BlobType) -> glm.Blob:
      if isinstance(blob, Mapping):
          blob = _convert_dict(blob)
  
      if isinstance(blob, glm.Blob):
          return blob
      elif isinstance(blob, IMAGE_TYPES):
          return image_to_blob(blob)
      else:
          if isinstance(blob, Mapping):
              raise KeyError(
                  "Could not recognize the intended type of the `dict`\n"
                  "A content should have "
              )
          raise TypeError(
              "Could not create `Blob`, expected `Blob`, `dict` or an `Image` type"
              "(`PIL.Image.Image` or `IPython.display.Image`).\n"
              f"Got a: {type(blob)}\n"
              f"Value: {blob}"
          )
  
imports: from __future__ import annotations
  from collections.abc import Iterable, Mapping
  import io
  import mimetypes
  import pathlib
  import typing
  from typing import Any, TypedDict, Union
  from google.ai import generativelanguage
label_desc: Use image node_id 5 for calling a global function with example usage: to_blob(blob) and returns: blob, image_to_blob