code: def fail_callback_output(output_value, output):
      valid_children = (str, int, float, type(None), Component)
      valid_props = (
          str,
          int,
          float,
          type(None),
          tuple,
          MutableSequence,
      )
  
      def _raise_invalid(
          bad_val, outer_val, path, index=None, toplevel=False
      ):
          bad_type = type(bad_val).__name__
          outer_id = (
              f"(id={outer_val.id:s})"
              if getattr(outer_val, "id", False)
              else ""
          )
          outer_type = type(outer_val).__name__
          if toplevel:
              location = dedent(
                  """
                  The value in question is either the only value returned,
                  or is in the top level of the returned list,
                  """
              )
          else:
              index_string = "[*]" if index is None else f"[{index:d}]"
              location = dedent(
                  f"""
                  The value in question is located at
                  {index_string} {outer_type} {outer_id}
                  {path},
                  """
              )
  
          obj = "tree with one value" if not toplevel else "value"
          raise exceptions.InvalidCallbackReturnValue(
              dedent(
                  f"""
                  The callback for `{output!r}`
                  returned a {obj:s} having type `{bad_type}`
                  which is not JSON serializable.
  
                  {location}
                  and has string representation
                  `{bad_val}`
  
                  In general, Dash properties can only be
                  dash components, strings, dictionaries, numbers, None,
                  or lists of those.
                  """
              )
          )
  
      def _valid_child(val):
          return isinstance(val, valid_children)
  
      def _valid_prop(val):
          return isinstance(val, valid_props)
  
      def _can_serialize(val):
          if not (_valid_child(val) or _valid_prop(val)):
              return False
          try:
              to_json(val)
          except TypeError:
              return False
          return True
  
      def _validate_value(val, index=None):
          # val is a Component
          if isinstance(val, Component):
              unserializable_items = []
              # pylint: disable=protected-access
              for p, j in val._traverse_with_paths():
                  # check each component value in the tree
                  if not _valid_child(j):
                      _raise_invalid(
                          bad_val=j, outer_val=val, path=p, index=index
                      )
  
                  if not _can_serialize(j):
                      # collect unserializable items separately, so we can report
                      # only the deepest level, not all the parent components that
                      # are just unserializable because of their children.
                      unserializable_items = [
                          i
                          for i in unserializable_items
                          if not p.startswith(i[0])
                      ]
                      if unserializable_items:
                          # we already have something unserializable in a different
                          # branch - time to stop and fail
                          break
                      if all(
                          not i[0].startswith(p)
                          for i in unserializable_items
                      ):
                          unserializable_items.append((p, j))
  
                  # Children that are not of type Component or
                  # list/tuple not returned by traverse
                  child = getattr(j, "children", None)
                  if not isinstance(child, (tuple, MutableSequence)):
                      if child and not _can_serialize(child):
                          _raise_invalid(
                              bad_val=child,
                              outer_val=val,
                              path=p
                              + "\n"
                              + "[*] "
                              + type(child).__name__,
                              index=index,
                          )
              if unserializable_items:
                  p, j = unserializable_items[0]
                  # just report the first one, even if there are multiple,
                  # as that's how all the other errors work
                  _raise_invalid(
                      bad_val=j, outer_val=val, path=p, index=index
                  )
  
              # Also check the child of val, as it will not be returned
              child = getattr(val, "children", None)
              if not isinstance(child, (tuple, MutableSequence)):
                  if child and not _can_serialize(val):
                      _raise_invalid(
                          bad_val=child,
                          outer_val=val,
                          path=type(child).__name__,
                          index=index,
                      )
  
          if not _can_serialize(val):
              _raise_invalid(
                  bad_val=val,
                  outer_val=type(val).__name__,
                  path="",
                  index=index,
                  toplevel=True,
              )
  
      if isinstance(output_value, list):
          for i, val in enumerate(output_value):
              _validate_value(val, index=i)
      else:
          _validate_value(output_value)
  
      # if we got this far, raise a generic JSON error
      raise exceptions.InvalidCallbackReturnValue(
          f"""
          The callback for output `{output!r}`
          returned a value which is not JSON serializable.
  
          In general, Dash properties can only be dash components, strings,
          dictionaries, numbers, None, or lists of those.
          """
      )
  
imports: from collections.abc import MutableSequence
  import re
  from textwrap import dedent
  from keyword import iskeyword
  import flask
  from ._grouping import grouping_len, map_grouping
  from .development.base_component import Component
  from .None import exceptions
  from ._utils import patch_collections_abc, stringify_id, to_json, coerce_to_list, clean_property_name
label_desc: Use image node_id 8 for calling a global function with example usage: fail_callback_output(output_value, output) and returns: isinstance, isinstance, True, False, False