code: def _collect_referred_local_functions(
      self,
      nodes,  # type: list[NodeProto]
  ):  # type: (...) -> list[FunctionProto]
      # a node in a model graph may refer a function.
      # a function contains nodes, some of which may in turn refer a function.
      # we need to find functions referred by graph nodes and
      # by nodes used to define functions.
      def find_referred_funcs(nodes, referred_local_functions):  # type: ignore
          new_nodes = []  # type: list[NodeProto]
          for node in nodes:
              # check if the node is a function op
              match_function = next(
                  (
                      f
                      for f in self.model.functions
                      if f.name == node.op_type
                      and f.domain == node.domain
                  ),
                  None,
              )
              if (
                  match_function
                  and match_function not in referred_local_functions
              ):
                  referred_local_functions.append(match_function)
                  new_nodes.extend(match_function.node)
  
          return new_nodes
  
      referred_local_functions = []  # type: list[FunctionProto]
      new_nodes = find_referred_funcs(nodes, referred_local_functions)
      while new_nodes:
          new_nodes = find_referred_funcs(
              new_nodes, referred_local_functions
          )
  
      return referred_local_functions
  
file_path: onnx/onnx/utils.py
imports: from __future__ import annotations
  import os
  import onnx.checker
  import onnx.helper
  import onnx.shape_inference
  from onnx import FunctionProto, ModelProto, NodeProto, TensorProto, ValueInfoProto
label_desc: Use image node_id 8 for calling the Extractor obj's underlying member method code with example usage: obj._collect_referred_local_functions(nodes) and returns: referred_local_functions, new_nodes