




"""simple docstring"""







from __future__ import annotations

import os
import tempfile
import unittest

from transformers import ConvBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
  import tensorflow as tf

  from transformers import (
      TFConvBertForMaskedLM,
      TFConvBertForMultipleChoice,
      TFConvBertForQuestionAnswering,
      TFConvBertForSequenceClassification,
      TFConvBertForTokenClassification,
      TFConvBertModel,
  )

class 				snake_case_			:







   """simple docstring"""




   def __init__(		self       ,					lowerCamelCase_       ,					lowerCamelCase_=1_3       ,					lowerCamelCase_=7       ,					lowerCamelCase_=True       ,					lowerCamelCase_=True       ,					lowerCamelCase_=True       ,					lowerCamelCase_=True       ,					lowerCamelCase_=9_9       ,					lowerCamelCase_=3_2       ,					lowerCamelCase_=2       ,					lowerCamelCase_=4       ,					lowerCamelCase_=3_7       ,					lowerCamelCase_="gelu"       ,					lowerCamelCase_=0.1       ,					lowerCamelCase_=0.1       ,					lowerCamelCase_=5_1_2       ,					lowerCamelCase_=1_6       ,					lowerCamelCase_=2       ,					lowerCamelCase_=0.02       ,					lowerCamelCase_=3       ,					lowerCamelCase_=4       ,					lowerCamelCase_=None       ,					)				->   Tuple:
       UpperCamelCase              =	parent
       UpperCamelCase              =	1_3
       UpperCamelCase              =	7
       UpperCamelCase              =	True
       UpperCamelCase              =	True
       UpperCamelCase              =	True
       UpperCamelCase              =	True
       UpperCamelCase              =	9_9
       UpperCamelCase              =	3_8_4
       UpperCamelCase              =	2
       UpperCamelCase              =	4
       UpperCamelCase              =	3_7
       UpperCamelCase              =	'''gelu'''
       UpperCamelCase              =	0.1
       UpperCamelCase              =	0.1
       UpperCamelCase              =	5_1_2
       UpperCamelCase              =	1_6
       UpperCamelCase              =	2
       UpperCamelCase              =	0.02
       UpperCamelCase              =	3
       UpperCamelCase              =	4
       UpperCamelCase              =	1_2_8
       UpperCamelCase              =	2
       UpperCamelCase              =	9
       UpperCamelCase              =	1
       UpperCamelCase              =	None







   def   UpperCAmelCase__			(		self)				->   int:
       UpperCamelCase              =	ids_tensor([self.batch_size, self.seq_length]       ,					self.vocab_size)

       UpperCamelCase              =	None
       if self.use_input_mask:
           UpperCamelCase              =	random_attention_mask([self.batch_size, self.seq_length])

       UpperCamelCase              =	None
       if self.use_token_type_ids:
           UpperCamelCase              =	ids_tensor([self.batch_size, self.seq_length]       ,					self.type_vocab_size)

       UpperCamelCase              =	None
       UpperCamelCase              =	None
       UpperCamelCase              =	None
       if self.use_labels:
           UpperCamelCase              =	ids_tensor([self.batch_size]       ,					self.type_sequence_label_size)
           UpperCamelCase              =	ids_tensor([self.batch_size, self.seq_length]       ,					self.num_labels)
           UpperCamelCase              =	ids_tensor([self.batch_size]       ,					self.num_choices)

       UpperCamelCase              =	ConvBertConfig(
           vocab_size=self.vocab_size       ,					hidden_size=self.hidden_size       ,					num_hidden_layers=self.num_hidden_layers       ,					num_attention_heads=self.num_attention_heads       ,					intermediate_size=self.intermediate_size       ,					hidden_act=self.hidden_act       ,					hidden_dropout_prob=self.hidden_dropout_prob       ,					attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,					max_position_embeddings=self.max_position_embeddings       ,					type_vocab_size=self.type_vocab_size       ,					initializer_range=self.initializer_range       ,					return_dict=lowerCamelCase_       ,					)

       return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_)				->   int:
       UpperCamelCase              =	TFConvBertModel(config=lowerCamelCase_)
       UpperCamelCase              =	{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

       UpperCamelCase              =	[input_ids, input_mask]
       UpperCamelCase              =	model(lowerCamelCase_)

       UpperCamelCase              =	model(lowerCamelCase_)

       self.parent.assertEqual(result.last_hidden_state.shape       ,					(self.batch_size, self.seq_length, self.hidden_size))







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_)				->   Union[str, Any]:
       UpperCamelCase              =	TFConvBertForMaskedLM(config=lowerCamelCase_)
       UpperCamelCase              =	{
           '''input_ids''': input_ids,
           '''attention_mask''': input_mask,
           '''token_type_ids''': token_type_ids,
       }
       UpperCamelCase              =	model(lowerCamelCase_)
       self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.seq_length, self.vocab_size))







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_)				->   Dict:
       UpperCamelCase              =	self.num_labels
       UpperCamelCase              =	TFConvBertForSequenceClassification(config=lowerCamelCase_)
       UpperCamelCase              =	{
           '''input_ids''': input_ids,
           '''attention_mask''': input_mask,
           '''token_type_ids''': token_type_ids,
       }

       UpperCamelCase              =	model(lowerCamelCase_)
       self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.num_labels))







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_)				->   Dict:
       UpperCamelCase              =	self.num_choices
       UpperCamelCase              =	TFConvBertForMultipleChoice(config=lowerCamelCase_)
       UpperCamelCase              =	tf.tile(tf.expand_dims(lowerCamelCase_       ,					1)       ,					(1, self.num_choices, 1))
       UpperCamelCase              =	tf.tile(tf.expand_dims(lowerCamelCase_       ,					1)       ,					(1, self.num_choices, 1))
       UpperCamelCase              =	tf.tile(tf.expand_dims(lowerCamelCase_       ,					1)       ,					(1, self.num_choices, 1))
       UpperCamelCase              =	{
           '''input_ids''': multiple_choice_inputs_ids,
           '''attention_mask''': multiple_choice_input_mask,
           '''token_type_ids''': multiple_choice_token_type_ids,
       }
       UpperCamelCase              =	model(lowerCamelCase_)
       self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.num_choices))







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_)				->   Tuple:
       UpperCamelCase              =	self.num_labels
       UpperCamelCase              =	TFConvBertForTokenClassification(config=lowerCamelCase_)
       UpperCamelCase              =	{
           '''input_ids''': input_ids,
           '''attention_mask''': input_mask,
           '''token_type_ids''': token_type_ids,
       }
       UpperCamelCase              =	model(lowerCamelCase_)
       self.parent.assertEqual(result.logits.shape       ,					(self.batch_size, self.seq_length, self.num_labels))







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					lowerCamelCase_)				->   Union[str, Any]:
       UpperCamelCase              =	TFConvBertForQuestionAnswering(config=lowerCamelCase_)
       UpperCamelCase              =	{
           '''input_ids''': input_ids,
           '''attention_mask''': input_mask,
           '''token_type_ids''': token_type_ids,
       }

       UpperCamelCase              =	model(lowerCamelCase_)
       self.parent.assertEqual(result.start_logits.shape       ,					(self.batch_size, self.seq_length))
       self.parent.assertEqual(result.end_logits.shape       ,					(self.batch_size, self.seq_length))







   def   UpperCAmelCase__			(		self)				->   str:
       UpperCamelCase              =	self.prepare_config_and_inputs()
       (
           (
           UpperCamelCase
       )       ,	(
           UpperCamelCase
       )       ,	(
           UpperCamelCase
       )       ,	(
           UpperCamelCase
       )       ,	(
           UpperCamelCase
       )       ,	(
           UpperCamelCase
       )       ,	(
           UpperCamelCase
       )       ,	
       )              =	config_and_inputs
       UpperCamelCase              =	{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
       return config, inputs_dict

@require_tf
class 				snake_case_			(					lowerCamelCase_	, lowerCamelCase_	, unittest.TestCase			):







   """simple docstring"""




   A_				      =       (
       (
           TFConvBertModel,
           TFConvBertForMaskedLM,
           TFConvBertForQuestionAnswering,
           TFConvBertForSequenceClassification,
           TFConvBertForTokenClassification,
           TFConvBertForMultipleChoice,
       )
       if is_tf_available()
       else ()
   )
   A_				      =       (
       {
           '''feature-extraction''': TFConvBertModel,
           '''fill-mask''': TFConvBertForMaskedLM,
           '''question-answering''': TFConvBertForQuestionAnswering,
           '''text-classification''': TFConvBertForSequenceClassification,
           '''token-classification''': TFConvBertForTokenClassification,
           '''zero-shot''': TFConvBertForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )
   A_				      =       False
   A_				      =       False
   A_				      =       False







   def   UpperCAmelCase__			(		self)				->   Dict:
       UpperCamelCase              =	TFConvBertModelTester(self)
       UpperCamelCase              =	ConfigTester(self       ,					config_class=lowerCamelCase_       ,					hidden_size=3_7)







   def   UpperCAmelCase__			(		self)				->   Optional[int]:
       self.config_tester.run_common_tests()







   def   UpperCAmelCase__			(		self)				->   Optional[Any]:
       UpperCamelCase              =	self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   int:
       UpperCamelCase              =	self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   int:
       UpperCamelCase              =	self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_multiple_choice(*lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   List[str]:
       UpperCamelCase              =	self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   Union[str, Any]:
       UpperCamelCase              =	self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   Tuple:
       UpperCamelCase              =	self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_token_classification(*lowerCamelCase_)







   @slow
   def   UpperCAmelCase__			(		self)				->   List[Any]:
       UpperCamelCase       ,	UpperCamelCase              =	self.model_tester.prepare_config_and_inputs_for_common()
       UpperCamelCase              =	True
       UpperCamelCase              =	True

       if hasattr(lowerCamelCase_       ,					'''use_cache'''):
           UpperCamelCase              =	True

       UpperCamelCase              =	getattr(self.model_tester       ,					'''encoder_seq_length'''       ,					self.model_tester.seq_length)
       UpperCamelCase              =	getattr(self.model_tester       ,					'''key_length'''       ,					lowerCamelCase_)

       for model_class in self.all_model_classes:
           UpperCamelCase              =	self._prepare_for_class(lowerCamelCase_       ,					lowerCamelCase_)
           UpperCamelCase              =	model_class(lowerCamelCase_)
           UpperCamelCase              =	len(model(lowerCamelCase_))

           with tempfile.TemporaryDirectory() as tmpdirname:
               model.save_pretrained(lowerCamelCase_       ,					saved_model=lowerCamelCase_)
               UpperCamelCase              =	os.path.join(lowerCamelCase_       ,					'''saved_model'''       ,					'''1''')
               UpperCamelCase              =	tf.keras.models.load_model(lowerCamelCase_)
               UpperCamelCase              =	model(lowerCamelCase_)

               if self.is_encoder_decoder:
                   UpperCamelCase              =	outputs['''encoder_hidden_states''']
                   UpperCamelCase              =	outputs['''encoder_attentions''']
               else:
                   UpperCamelCase              =	outputs['''hidden_states''']
                   UpperCamelCase              =	outputs['''attentions''']

               self.assertEqual(len(lowerCamelCase_)       ,					lowerCamelCase_)

               UpperCamelCase              =	getattr(
                   self.model_tester       ,					'''expected_num_hidden_layers'''       ,					self.model_tester.num_hidden_layers + 1)

               self.assertEqual(len(lowerCamelCase_)       ,					lowerCamelCase_)
               self.assertListEqual(
                   list(output_hidden_states[0].shape[-2:])       ,					[self.model_tester.seq_length, self.model_tester.hidden_size]       ,					)

               self.assertEqual(len(lowerCamelCase_)       ,					self.model_tester.num_hidden_layers)
               self.assertListEqual(
                   list(output_attentions[0].shape[-3:])       ,					[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]       ,					)







   @slow
   def   UpperCAmelCase__			(		self)				->   List[str]:
       UpperCamelCase              =	TFConvBertModel.from_pretrained('''YituTech/conv-bert-base''')
       self.assertIsNotNone(lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   Union[str, Any]:
       UpperCamelCase       ,	UpperCamelCase              =	self.model_tester.prepare_config_and_inputs_for_common()
       UpperCamelCase              =	True
       UpperCamelCase              =	getattr(self.model_tester       ,					'''decoder_seq_length'''       ,					self.model_tester.seq_length)
       UpperCamelCase              =	getattr(self.model_tester       ,					'''encoder_seq_length'''       ,					self.model_tester.seq_length)
       UpperCamelCase              =	getattr(self.model_tester       ,					'''key_length'''       ,					lowerCamelCase_)
       UpperCamelCase              =	getattr(self.model_tester       ,					'''key_length'''       ,					lowerCamelCase_)

       def check_decoder_attentions_output(lowerCamelCase_):
           UpperCamelCase              =	len(lowerCamelCase_)
           self.assertEqual(out_len % 2       ,					0)
           UpperCamelCase              =	outputs.decoder_attentions
           self.assertEqual(len(lowerCamelCase_)       ,					self.model_tester.num_hidden_layers)
           self.assertListEqual(
               list(decoder_attentions[0].shape[-3:])       ,					[self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]       ,					)

       def check_encoder_attentions_output(lowerCamelCase_):
           UpperCamelCase              =	[
               t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
           ]
           self.assertEqual(len(lowerCamelCase_)       ,					self.model_tester.num_hidden_layers)
           self.assertListEqual(
               list(attentions[0].shape[-3:])       ,					[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]       ,					)

       for model_class in self.all_model_classes:
           UpperCamelCase              =	True
           UpperCamelCase              =	False
           UpperCamelCase              =	model_class(lowerCamelCase_)
           UpperCamelCase              =	model(self._prepare_for_class(lowerCamelCase_       ,					lowerCamelCase_))
           UpperCamelCase              =	len(lowerCamelCase_)
           self.assertEqual(config.output_hidden_states       ,					lowerCamelCase_)
           check_encoder_attentions_output(lowerCamelCase_)

           if self.is_encoder_decoder:
               UpperCamelCase              =	model_class(lowerCamelCase_)
               UpperCamelCase              =	model(self._prepare_for_class(lowerCamelCase_       ,					lowerCamelCase_))
               self.assertEqual(config.output_hidden_states       ,					lowerCamelCase_)
               check_decoder_attentions_output(lowerCamelCase_)

           # Check that output attentions can also be changed via the config
           del inputs_dict["output_attentions"]
           UpperCamelCase              =	True
           UpperCamelCase              =	model_class(lowerCamelCase_)
           UpperCamelCase              =	model(self._prepare_for_class(lowerCamelCase_       ,					lowerCamelCase_))
           self.assertEqual(config.output_hidden_states       ,					lowerCamelCase_)
           check_encoder_attentions_output(lowerCamelCase_)

           # Check attention is always last and order is fine
           UpperCamelCase              =	True
           UpperCamelCase              =	True
           UpperCamelCase              =	model_class(lowerCamelCase_)
           UpperCamelCase              =	model(self._prepare_for_class(lowerCamelCase_       ,					lowerCamelCase_))

           self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)       ,					len(lowerCamelCase_))
           self.assertEqual(model.config.output_hidden_states       ,					lowerCamelCase_)
           check_encoder_attentions_output(lowerCamelCase_)

@require_tf
class 				snake_case_			(					unittest.TestCase			):







   """simple docstring"""




   @slow
   def   UpperCAmelCase__			(		self)				->   List[str]:
       UpperCamelCase              =	TFConvBertModel.from_pretrained('''YituTech/conv-bert-base''')
       UpperCamelCase              =	tf.constant([[0, 1, 2, 3, 4, 5]])
       UpperCamelCase              =	model(lowerCamelCase_)[0]

       UpperCamelCase              =	[1, 6, 7_6_8]
       self.assertEqual(output.shape       ,					lowerCamelCase_)

       UpperCamelCase              =	tf.constant(
           [
               [
                   [-0.0347_5493, -0.468_6034, -0.3063_8832],
                   [0.2263_7248, -0.2698_8646, -0.742_3424],
                   [0.1032_4868, -0.4501_3508, -0.5828_0784],
               ]
           ])
       tf.debugging.assert_near(output[:, :3, :3]       ,					lowerCamelCase_       ,					atol=1e-4)





import os

import numpy
import onnx





def        __UpperCAmelCase						(							lowerCamelCase_ :     str  ,							lowerCamelCase_ :     Optional[Any]  )       ->  Optional[int]:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : int					  =      a.name
			SCREAMING_SNAKE_CASE_   : Dict					  =      b.name

			SCREAMING_SNAKE_CASE_   : str					  =      ''
			SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      ''

			SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      a == b

			SCREAMING_SNAKE_CASE_   : str					  =      name_a
			SCREAMING_SNAKE_CASE_   : str					  =      name_b

			return res





def        __UpperCAmelCase						(							lowerCamelCase_ :     int  ,							lowerCamelCase_ :     str  ,							lowerCamelCase_ :     Dict  )       ->  Optional[int]:







			"""simple docstring"""





			for i, input_name in enumerate(node_proto.input  ):
						if input_name == name:
									node_proto.input.insert(lowerCamelCase_  ,							lowerCamelCase_  )
									node_proto.input.pop(i + 1  )

			if node_proto.op_type == "If":
						_graph_replace_input_with(node_proto.attribute[0].g  ,							lowerCamelCase_  ,							lowerCamelCase_  )
						_graph_replace_input_with(node_proto.attribute[1].g  ,							lowerCamelCase_  ,							lowerCamelCase_  )
			if node_proto.op_type == "Loop":
						_graph_replace_input_with(node_proto.attribute[0].g  ,							lowerCamelCase_  ,							lowerCamelCase_  )





def        __UpperCAmelCase						(							lowerCamelCase_ :     Tuple  ,							lowerCamelCase_ :     Optional[int]  ,							lowerCamelCase_ :     Dict  )       ->  List[Any]:







			"""simple docstring"""





			for n in graph_proto.node:
						_node_replace_input_with(lowerCamelCase_  ,							lowerCamelCase_  ,							lowerCamelCase_  )





def        __UpperCAmelCase						(							lowerCamelCase_ :     Tuple  ,							lowerCamelCase_ :     Tuple  ,							lowerCamelCase_ :     Any  )       ->  str:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : str					  =      list(model.graph.initializer  )
			SCREAMING_SNAKE_CASE_   : List[str]					  =      list(model_without_ext.graph.initializer  )
			for i, ref_i in ind_to_replace:
						assert inits_with_data[i].name == inits[i].name
						assert inits_with_data[ref_i].name == inits[ref_i].name
						assert i > ref_i

						SCREAMING_SNAKE_CASE_   : List[str]					  =      inits[i].name
						SCREAMING_SNAKE_CASE_   : str					  =      inits[ref_i].name

						model_without_ext.graph.initializer.remove(inits[i]  )

						# for n in model.graph.node:
						_graph_replace_input_with(model_without_ext.graph  ,							lowerCamelCase_  ,							lowerCamelCase_  )





def        __UpperCAmelCase						(							lowerCamelCase_ :     Dict  )       ->  Dict:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Tuple					  =      os.path.dirname(lowerCamelCase_  )
			SCREAMING_SNAKE_CASE_   : Tuple					  =      os.path.basename(lowerCamelCase_  )

			SCREAMING_SNAKE_CASE_   : int					  =      onnx.load(os.path.join(lowerCamelCase_  ,							lowerCamelCase_  )  )

			SCREAMING_SNAKE_CASE_   : Any					  =      list(model.graph.initializer  )

			SCREAMING_SNAKE_CASE_   : int					  =      set()
			SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      {}
			SCREAMING_SNAKE_CASE_   : Dict					  =      []

			SCREAMING_SNAKE_CASE_   : int					  =      0

			for i in range(len(lowerCamelCase_  )  ):
						if i in dup_set:
									continue

						for j in range(i + 1  ,							len(lowerCamelCase_  )  ):
									if j in dup_set:
												continue
									if _is_equal_tensor_proto(inits[i]  ,							inits[j]  ):
												dup_set.add(lowerCamelCase_  )
												dup_set.add(lowerCamelCase_  )

												SCREAMING_SNAKE_CASE_   : int					  =      inits[j].data_type
												SCREAMING_SNAKE_CASE_   : str					  =      numpy.prod(inits[j].dims  )
												if dtype == 1:
															mem_size *= 4
												elif dtype == 6:
															mem_size *= 4
												elif dtype == 7 or dtype == 11:
															mem_size *= 8
												else:
															print('unexpected data type: '  ,							lowerCamelCase_  )
												total_reduced_size += mem_size

												SCREAMING_SNAKE_CASE_   : int					  =      inits[i].name
												SCREAMING_SNAKE_CASE_   : List[Any]					  =      inits[j].name

												if name_i in dup_map:
															dup_map[name_i].append(lowerCamelCase_  )
												else:
															SCREAMING_SNAKE_CASE_   : Optional[int]					  =      [name_j]
												ind_to_replace.append((j, i)  )

			print('total reduced size: '  ,							total_reduced_size / 10_24 / 10_24 / 10_24  ,							'GB'  )

			SCREAMING_SNAKE_CASE_   : int					  =      sorted(lowerCamelCase_  )
			_remove_dup_initializers_from_model(lowerCamelCase_  ,							lowerCamelCase_  ,							lowerCamelCase_  )

			SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      'optimized_' + model_file_name
			SCREAMING_SNAKE_CASE_   : Optional[int]					  =      os.path.join(lowerCamelCase_  ,							lowerCamelCase_  )
			onnx.save(lowerCamelCase_  ,							lowerCamelCase_  )

			return new_model



