code: def _check_cycle(
      nodes: Iterable[str], dependencies: Mapping[str, Iterable[str]]
  ):
      """Check whether the graph has the cycle."""
      visiting = set()
      visited = set()
  
      def dfs(here):
          if here in visiting:
              raise exceptions.FailedPreconditionError(
                  f"NodeInputs has a cycle. dependencies = {dependencies}"
              )
          if here not in visited:
              visiting.add(here)
              for there in dependencies[here]:
                  dfs(there)
              visiting.remove(here)
              visited.add(here)
  
      for node in nodes:
          dfs(node)
  
imports: import collections
  from typing import Dict, Iterable, List, Mapping, Sequence, Tuple, TypeVar
  from tfx import types
  from tfx.dsl.compiler import placeholder_utils
  from tfx.orchestration import metadata
  from tfx.orchestration import mlmd_connection_manager
  from tfx.orchestration.portable import data_types
  from tfx.orchestration.portable.input_resolution import exceptions
  from tfx.orchestration.portable.input_resolution import input_graph_resolver
  from tfx.orchestration.portable.input_resolution import partition_utils
  from tfx.orchestration.portable.input_resolution import channel_resolver
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.types import artifact_utils
  from tfx.utils import topsort
  from tfx.utils import typing_utils
  from tfx.utils import governance_utils
label_desc: Use image node_id 2 for calling a global function with example usage: _check_cycle(nodes, dependencies) without return types