code: def ensure_topological_order(nodes: List[base_node.BaseNode]) -> bool:
      """Helper function to check if nodes are topologically sorted."""
      visited = set()
      for node in nodes:
          for upstream_node in node.upstream_nodes:
              if upstream_node not in visited:
                  return False
          visited.add(node)
      return True
  
imports: from typing import cast, List, Optional, Sequence, Tuple, Type, Union, Dict, Any, Set
  from tfx import types
  from tfx.dsl.compiler import constants
  from tfx.dsl.components.base import base_node
  from tfx.dsl.components.common import importer
  from tfx.dsl.components.common import resolver
  from tfx.dsl.context_managers import dsl_context_registry
  from tfx.dsl.placeholder import placeholder
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import pipeline
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.types import channel
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 6 for calling a global function with example usage: ensure_topological_order(nodes) and returns: True, False