code: def _collect_reachable_nodes(
      self,
      input_names: List[str],
      output_names: List[str],
  ) -> List[NodeProto]:
      reachable_nodes = []  # type: ignore[var-annotated]
      for name in output_names:
          self._dfs_search_reachable_nodes(
              name, input_names, reachable_nodes
          )
      # needs to be topology sorted.
      nodes = [n for n in self.graph.node if n in reachable_nodes]
      return nodes
  
file_path: catboost/contrib/libs/onnx/onnx/utils.py
imports: import os
  from typing import List, Tuple
  import onnx.checker
  import onnx.helper
  import onnx.shape_inference
  from onnx import FunctionProto, ModelProto, NodeProto, TensorProto, ValueInfoProto
label_desc: Use image node_id 7 for calling the Extractor obj's underlying member method code with example usage: obj._collect_reachable_nodes(input_names, output_names) and returns: nodes