code: def serialize_template_field(
      template_field: Any,
  ) -> str | dict | list | int | float:
      """Return a serializable representation of the templated field.
  
      If ``templated_field`` contains a class or instance that requires recursive
      templating, store them as strings. Otherwise simply return the field as-is.
      """
  
      def is_jsonable(x):
          try:
              json.dumps(x)
          except (TypeError, OverflowError):
              return False
          else:
              return True
  
      if not is_jsonable(template_field):
          return str(template_field)
      else:
          return template_field
  
imports: from __future__ import annotations
  from typing import Any
  from airflow.settings import json
label_desc: Use image node_id 1 for calling a global function with example usage: serialize_template_field(template_field) and returns: str, template_field, True, False