code: def to_contents(contents: ContentsType) -> list[glm.Content]:
      if contents is None:
          return []
  
      if isinstance(contents, Iterable) and not isinstance(
          contents, (str, Mapping)
      ):
          try:
              # strict_to_content so [[parts], [parts]] doesn't assume roles.
              contents = [strict_to_content(c) for c in contents]
              return contents
          except TypeError:
              # If you get a TypeError here it's probably because that was a list
              # of parts, not a list of contents, so fall back to `to_content`.
              pass
  
      contents = [to_content(contents)]
      return contents
  
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 11 for calling a global function with example usage: to_contents(contents) and returns: contents, list, contents