class_docstr: For each function, this pass renames ops and variables with the same name
  as any preceding ops/variables across all scopes in the given function,
  where the precedence is implementation-specific. Note that an op name and
  variable names are tracked separately, so an op may have the same name as
  a variable.
  
  The pass preserves input and output name. Raises ValueError if we cannot
  dedup without changing the input/output var names.
  
  .. code-block::
  
      def prog(x):
          x = mb.cast(x=x, dtype="fp16", name="castop")
          x = mb.cast(x=x, dtype="fp32", name="castop")
          x = mb.square(x=x, name="square_last")
          return x
  
      # Before dedup pass, the op names are ["castop", "castop", "square_last"].
      # After dedup pass, the op names are ["castop", "castop_1", "square_last"].
class_docstr_tok: ["For","each","function",",","this","pass","renames","ops","and","variables","with","the","same","name","as","any","preceding","ops\/variables","across","all","scopes","in","the","given","function",",","where","the","precedence","is","implementation-specific",".","Note","that","an","op","name","and","variable","names","are","tracked","separately",",","so","an","op","may","have","the","same","name","as","a","variable",".","The","pass","preserves","input","and","output","name",".","Raises","ValueError","if","we","can","not","dedup","without","changing","the","input\/output","var","names",".","..","code-block",":",":","def","prog","(","x",")",":","x","=","mb.cast","(","x=x",",","dtype=","''","fp16","''",",","name=","''","castop","''",")","x","=","mb.cast","(","x=x",",","dtype=","''","fp32","''",",","name=","''","castop","''",")","x","=","mb.square","(","x=x",",","name=","''","square_last","''",")","return","x","#","Before","dedup","pass",",","the","op","names","are","[","``","castop","''",",","``","castop","''",",","``","square_last","''","]",".","#","After","dedup","pass",",","the","op","names","are","[","``","castop","''",",","``","castop_1","''",",","``","square_last","''","]","."]
docstr: seen_var_names: set[str]
  seen_op_names: set[str]
docstr_tok: ["seen_var_names",":","set","[","str","]","seen_op_names",":","set","[","str","]"]
code: def _deduplicate_block(
      self, block, func_outputs, seen_var_names, seen_op_names
  ):
      """
      seen_var_names: set[str]
      seen_op_names: set[str]
      """
      # Add block input (function input is handled separately)
      if not isinstance(block, Function):
          for v in block.inputs:
              v.name = self._gen_new_name(seen_var_names, v.name)
              seen_var_names.add(v.name)
  
      for op in list(block.operations):
          for b in op.blocks:
              self._deduplicate_block(
                  b, func_outputs, seen_var_names, seen_op_names
              )
          if op.name is not None:
              op.name = self._gen_new_name(seen_op_names, op.name)
              seen_op_names.add(op.name)
          for v in op.outputs:
              if v in func_outputs:
                  # func output is never renamed
                  continue
              v.name = self._gen_new_name(seen_var_names, v.name)
              seen_var_names.add(v.name)
  
file_path: coremltools/coremltools/converters/mil/mil/passes/defs/cleanup/dedup_op_and_var_names.py
imports: import collections
  import itertools
  from coremltools.converters.mil.mil import Function
  from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
label_desc: Use image node_id 3 for calling the dedup_op_and_var_names obj's underlying member method code with example usage: obj._deduplicate_block(block, func_outputs, seen_var_names, seen_op_names) without return types