code: def remove_duplicate_weights(
      model: ModelProto, inplace: bool = False
  ) -> ModelProto:
      """
      Finds and removes duplicate weights in a model by keeping only unique weights, and make the duplicate values point
      to them.
  
      This function only removes duplicate weights that are exactly identical (e.g., not transposed).
  
      Args:
          model (`onnx.ModelProto`): The model to remove duplicates from.
          inplace (`bool`, defaults to False): Whether to perform this transformation inplace.
  
      Returns:
          `onnx.ModelProto`: The model without duplicates.
      """
      if not inplace:
          model = copy.deepcopy(model)
      duplicates = _find_duplicate_initializers(models=[model])
      name_sharing_dict = _create_name_sharing_dict(duplicates)
  
      _replace_input_names(
          models=[model], name_sharing_dict=name_sharing_dict
      )
      _remove_redundant_initializers(
          models=[model], name_sharing_dict=name_sharing_dict
      )
  
      return model
  
file_path: optimum/optimum/onnx/graph_transformations.py
imports: import copy
  import os
  from pathlib import Path
  from typing import TYPE_CHECKING, List, Optional, Union
  import onnx
  from onnx import ModelProto
  from ..utils import logging
  from .transformations_utils import _create_name_sharing_dict, _deduplicate_gather_matmul, _deduplicated_cross_model_initializers, _find_duplicate_initializers, _find_matching_initializers, _get_all_inputs, _get_onnx_opset, _get_weights_to_tie, _remove_redundant_initializers, _replace_input_names, _unify_onnx_outputs, cast_int64_tensorproto_to_int32
label_desc: Use image node_id 1 for calling a global function with example usage: remove_duplicate_weights(model, inplace) and returns: model