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","''","]","."]
code: def _gen_new_name(seen_names, curr_name):
      if curr_name not in seen_names:
          return curr_name
      # make sure the name is unique
      for i in itertools.count(start=1):  # loop from 1 to infinity
          # rename duplicated name start from 1: 'xxx_1'
          new_name = curr_name + "_" + str(i)
          if new_name not in seen_names:
              return new_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 2 for calling the dedup_op_and_var_names obj's underlying member method code with example usage: obj._gen_new_name(seen_names, curr_name) and returns: curr_name, new_name