code: def submodel_has_python_callbacks(
      models: Sequence[Model | Document],
  ) -> bool:
      """Traverses submodels to check for Python (event) callbacks"""
      has_python_callback = False
      for model in collect_models(models):
          if (
              len(model._callbacks) > 0
              or len(model._event_callbacks) > 0
          ):
              has_python_callback = True
              break
  
      return has_python_callback
  
imports: from __future__ import annotations
  import logging
  import re
  from contextlib import contextmanager
  from typing import TYPE_CHECKING, Any, Iterator, Sequence
  from weakref import WeakKeyDictionary
  from ..core.types import ID
  from ..document.document import Document
  from ..model import Model, collect_models
  from ..settings import settings
  from ..themes.theme import Theme
  from ..util.dataclasses import dataclass, field
  from ..util.serialization import make_globally_unique_css_safe_id, make_globally_unique_id
label_desc: Use image node_id 4 for calling a global function with example usage: submodel_has_python_callbacks(models) and returns: has_python_callback