code: def check_acyclic(graph: "DiGraph") -> None:
      import networkx as nx
  
      from dvc.exceptions import CyclicGraphError
  
      try:
          edges = nx.find_cycle(graph, orientation="original")
      except nx.NetworkXNoCycle:
          return
  
      stages: Set["Stage"] = set()
      for from_node, to_node, _ in edges:
          stages.add(from_node)
          stages.add(to_node)
  
      raise CyclicGraphError(list(stages))
  
file_path: dvc/dvc/repo/graph.py
imports: from typing import TYPE_CHECKING, Any, Iterator, List, Optional, Set, TypeVar
  from dvc.fs import localfs
  from dvc.utils.fs import path_isin
label_desc: Use image node_id 1 for calling a global function with example usage: check_acyclic(graph) without return types