class_docstr: Remove duplicated large constants (tensor with 100+ elements)
  
  For example
  
  .. code-block::
  
      Input graph (where weight and bias are large constants):
          weight_q = const(weight)
          weight_k = const(weight)
          bias_q = const(bias)
          bias_k = const(bias)
          q_embedding = linear(x=q, weight=weight_q, bias=bias_q)
          k_embedding = linear(x=k, weight=weight_k, bias=bias_k)
  
      Output graph:
          weight_q = const(weight)
          bias_q = const(bias)
          q_embedding = linear(x=q, weight=weight_q, bias=bias_q)
          k_embedding = linear(x=k, weight=weight_q, bias=bias_q)
  
  Concretely, this graph pass consists of two stages:
  
  (1) Deduplication of ``const`` op:
  
      We consider a ``const`` as duplicated if there exists such a previous ``const`` that has same dtype and value
  
  (2) Deduplication of ``constexpr_*`` op:
  
      We consider a ``constexpr_*`` as duplicated if there exists such a previous ``constexpr_*`` that has the same ``op_type`` and input attributes.
docstr: Given a block, return all constexpr in the block in such a format:
      {unique_var_0: [duplicated_var_0_0, duplicated_var_0_1, ...],
       unique_var_1: [duplicated_var_1_0, duplicated_var_1_1, ...],
       ...
      }
docstr_tok: ["Given","a","block",",","return","all","constexpr","in","the","block","in","such","a","format",":","{","unique_var_0",":","[","duplicated_var_0_0",",","duplicated_var_0_1",",","...","]",",","unique_var_1",":","[","duplicated_var_1_0",",","duplicated_var_1_1",",","...","]",",","...","}"]
code: def find_constexprs(self, block: Block) -> Dict[Var, List[Var]]:
      """
      Given a block, return all constexpr in the block in such a format:
          {unique_var_0: [duplicated_var_0_0, duplicated_var_0_1, ...],
           unique_var_1: [duplicated_var_1_0, duplicated_var_1_1, ...],
           ...
          }
      """
      hashkey_2_duplicates: Dict[Tuple, List[Var]] = {}
      for op in list(block.operations):
          if "constexpr" in op.op_type:
              hash_key = [op.op_type]
              for v in op.inputs.values():
                  hash_key.append(v.dtype)
                  if np.prod(v.shape) < self.NUMEL_THRESH:
                      hash_key.append(str(v.val))
                  else:
                      hash_key.append(v)
              hash_key = tuple(hash_key)
              if hash_key not in hashkey_2_duplicates:
                  hashkey_2_duplicates[hash_key] = [op.outputs[0]]
              else:
                  hashkey_2_duplicates[hash_key].append(op.outputs[0])
  
      return {v[0]: v[1:] for v in hashkey_2_duplicates.values()}
  
file_path: coremltools/coremltools/converters/mil/mil/passes/defs/cleanup/const_deduplication.py
imports: import hashlib
  from typing import Dict, List, Tuple
  import numpy
  from coremltools.converters.mil.mil import Block, Var, ListVar, types
  from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass
  from coremltools.converters.mil.mil.passes.helper import block_context_manager
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
label_desc: Use image node_id 4 for calling the const_deduplication obj's underlying member method code with example usage: obj.find_constexprs(block) and returns: unknown