code: def add_prefix(
      model: ModelProto,
      prefix: str,
      rename_nodes: Optional[bool] = True,
      rename_edges: Optional[bool] = True,
      rename_inputs: Optional[bool] = True,
      rename_outputs: Optional[bool] = True,
      rename_initializers: Optional[bool] = True,
      rename_value_infos: Optional[bool] = True,
      rename_functions: Optional[bool] = True,
      inplace: Optional[bool] = False,
  ) -> ModelProto:
      """Adds a prefix to names of elements in a graph: nodes, edges, inputs, outputs,
      initializers, sparse initializer, value infos, and local functions.
  
      It can be used as a utility before merging graphs that have overlapping names.
      Empty names are not _prefixed.
  
      Arguments:
          model (ModelProto): Model
          prefix (str): Prefix to be added to each name in the graph
          rename_nodes (bool): Whether to prefix node names
          rename_edges (bool): Whether to prefix node edge names
          rename_inputs (bool): Whether to prefix input names
          rename_outputs (bool): Whether to prefix output names
          rename_initializers (bool): Whether to prefix initializer and sparse initializer names
          rename_value_infos (bool): Whether to prefix value info nanes
          rename_functions (bool): Whether to prefix local function names
          inplace (bool): If True, mutates the model directly.
                          Otherwise, a copy will be created
  
      Returns:
          ModelProto
      """
      if type(model) is not ModelProto:
          raise ValueError("model argument is not an ONNX model")
  
      if not inplace:
          m = ModelProto()
          m.CopyFrom(model)
          model = m
  
      add_prefix_graph(
          model.graph,
          prefix,
          rename_nodes=rename_nodes,
          rename_edges=rename_edges,
          rename_inputs=rename_inputs,
          rename_outputs=rename_outputs,
          rename_initializers=rename_initializers,
          rename_value_infos=rename_value_infos,
          inplace=True,  # No need to create a copy, since it's a new model
      )
  
      if rename_functions:
          f_name_map = {}
          for f in model.functions:
              new_f_name = prefix + f.name
              f_name_map[f.name] = new_f_name
              f.name = new_f_name
          # Adjust references to local functions in other local function
          # definitions
          for f in model.functions:
              for n in f.node:
                  if n.op_type in f_name_map:
                      n.op_type = f_name_map[n.op_type]
          # Adjust references to local functions in the graph
          for n in model.graph.node:
              if n.op_type in f_name_map:
                  n.op_type = f_name_map[n.op_type]
  
      return model
  
file_path: onnx/onnx/compose.py
imports: from typing import Dict, List, MutableMapping, Optional, Set, Tuple
  from onnx import GraphProto, ModelProto, TensorProto, checker, helper, utils
label_desc: Use image node_id 5 for calling a global function with example usage: add_prefix(model, prefix, rename_nodes, rename_edges, rename_inputs, rename_outputs, rename_initializers, rename_value_infos, rename_functions, inplace) and returns: model