



import unittest

from transformers import ElectraConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    MODEL_FOR_PRETRAINING_MAPPING,
		    ElectraForCausalLM,
		    ElectraForMaskedLM,
		    ElectraForMultipleChoice,
		    ElectraForPreTraining,
		    ElectraForQuestionAnswering,
		    ElectraForSequenceClassification,
		    ElectraForTokenClassification,
		    ElectraModel,
		)
		from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST


class 	a__       :


					"""simple docstring"""



					def __init__(		self     :List[Any]      ,  lowercase__     :Optional[Any]      ,  lowercase__     :str=13      ,  lowercase__     :Union[str, Any]=7      ,  lowercase__     :Tuple=True      ,  lowercase__     :Union[str, Any]=True      ,  lowercase__     :Any=True      ,  lowercase__     :str=True      ,  lowercase__     :str=99      ,  lowercase__     :int=32      ,  lowercase__     :Optional[int]=5      ,  lowercase__     :List[str]=4      ,  lowercase__     :List[Any]=37      ,  lowercase__     :Tuple="gelu"      ,  lowercase__     :Optional[Any]=0.1      ,  lowercase__     :Union[str, Any]=0.1      ,  lowercase__     :List[Any]=512      ,  lowercase__     :Dict=16      ,  lowercase__     :str=2      ,  lowercase__     :List[Any]=0.02      ,  lowercase__     :Tuple=3      ,  lowercase__     :Dict=4      ,  lowercase__     :List[Any]=None      ,  ):
										lowercase						   =       parent
										lowercase						   =       batch_size
										lowercase						   =       seq_length
										lowercase						   =       is_training
										lowercase						   =       use_input_mask
										lowercase						   =       use_token_type_ids
										lowercase						   =       use_labels
										lowercase						   =       vocab_size
										lowercase						   =       hidden_size
										lowercase						   =       num_hidden_layers
										lowercase						   =       num_attention_heads
										lowercase						   =       intermediate_size
										lowercase						   =       hidden_act
										lowercase						   =       hidden_dropout_prob
										lowercase						   =       attention_probs_dropout_prob
										lowercase						   =       max_position_embeddings
										lowercase						   =       type_vocab_size
										lowercase						   =       type_sequence_label_size
										lowercase						   =       initializer_range
										lowercase						   =       num_labels
										lowercase						   =       num_choices
										lowercase						   =       scope

					def 				__UpperCAmelCase		(		self     :Optional[Any]    ):
										lowercase						   =       ids_tensor([self.batch_size, self.seq_length]      ,  self.vocab_size    )

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

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

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

										lowercase						   =       self.get_config()

										return (
										    config,
										    input_ids,
										    token_type_ids,
										    input_mask,
										    sequence_labels,
										    token_labels,
										    choice_labels,
										    fake_token_labels,
										)

					def 				__UpperCAmelCase		(		self     :str    ):
										return ElectraConfig(
										    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      ,  is_decoder=__UpperCAmelCase      ,  initializer_range=self.initializer_range      ,  )

					def 				__UpperCAmelCase		(		self     :List[Any]    ):
										(
										    (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,         
										)						   =       self.prepare_config_and_inputs()

										lowercase						   =       True
										lowercase						   =       floats_tensor([self.batch_size, self.seq_length, self.hidden_size]    )
										lowercase						   =       ids_tensor([self.batch_size, self.seq_length]      ,  vocab_size=2    )

										return (
										    config,
										    input_ids,
										    token_type_ids,
										    input_mask,
										    sequence_labels,
										    token_labels,
										    choice_labels,
										    encoder_hidden_states,
										    encoder_attention_mask,
										)

					def 				__UpperCAmelCase		(		self     :Union[str, Any]      ,  lowercase__     :List[str]      ,  lowercase__     :Optional[Any]      ,  lowercase__     :Dict      ,  lowercase__     :Tuple      ,  lowercase__     :Union[str, Any]      ,  lowercase__     :int      ,  lowercase__     :List[str]      ,  lowercase__     :Optional[int]      ,  ):
										lowercase						   =       ElectraModel(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase    )
										lowercase						   =       model(__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase    )
										lowercase						   =       model(__UpperCAmelCase    )
										self.parent.assertEqual(result.last_hidden_state.shape      ,  (self.batch_size, self.seq_length, self.hidden_size)    )

					def 				__UpperCAmelCase		(		self     :int      ,  lowercase__     :Optional[int]      ,  lowercase__     :Any      ,  lowercase__     :str      ,  lowercase__     :Optional[Any]      ,  lowercase__     :Dict      ,  lowercase__     :Any      ,  lowercase__     :Any      ,  lowercase__     :int      ,  lowercase__     :Tuple      ,  ):
										lowercase						   =       True
										lowercase						   =       ElectraModel(__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(
										    __UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  encoder_hidden_states=__UpperCAmelCase      ,  encoder_attention_mask=__UpperCAmelCase      ,  )
										lowercase						   =       model(
										    __UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  encoder_hidden_states=__UpperCAmelCase      ,  )
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase    )
										self.parent.assertEqual(result.last_hidden_state.shape      ,  (self.batch_size, self.seq_length, self.hidden_size)    )

					def 				__UpperCAmelCase		(		self     :List[str]      ,  lowercase__     :List[Any]      ,  lowercase__     :List[Any]      ,  lowercase__     :str      ,  lowercase__     :Optional[int]      ,  lowercase__     :List[Any]      ,  lowercase__     :Dict      ,  lowercase__     :Union[str, Any]      ,  lowercase__     :Tuple      ,  ):
										lowercase						   =       ElectraForMaskedLM(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  labels=__UpperCAmelCase    )
										self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length, self.vocab_size)    )

					def 				__UpperCAmelCase		(		self     :Union[str, Any]      ,  lowercase__     :Optional[Any]      ,  lowercase__     :List[str]      ,  lowercase__     :List[Any]      ,  lowercase__     :Any      ,  lowercase__     :str      ,  lowercase__     :List[str]      ,  lowercase__     :Dict      ,  lowercase__     :Tuple      ,  lowercase__     :List[str]      ,  ):
										lowercase						   =       ElectraForCausalLM(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  labels=__UpperCAmelCase    )
										self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length, self.vocab_size)    )

					def 				__UpperCAmelCase		(		self     :Union[str, Any]      ,  lowercase__     :str      ,  lowercase__     :List[str]      ,  lowercase__     :Optional[int]      ,  lowercase__     :Optional[Any]      ,  lowercase__     :Tuple      ,  lowercase__     :int      ,  lowercase__     :List[str]      ,  lowercase__     :Any      ,  ):
										lowercase						   =       self.num_labels
										lowercase						   =       ElectraForTokenClassification(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  labels=__UpperCAmelCase    )
										self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length, self.num_labels)    )

					def 				__UpperCAmelCase		(		self     :List[str]      ,  lowercase__     :Union[str, Any]      ,  lowercase__     :int      ,  lowercase__     :List[Any]      ,  lowercase__     :Union[str, Any]      ,  lowercase__     :str      ,  lowercase__     :Tuple      ,  lowercase__     :int      ,  lowercase__     :str      ,  ):
										lowercase						   =       self.num_labels
										lowercase						   =       ElectraForPreTraining(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  labels=__UpperCAmelCase    )
										self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.seq_length)    )

					def 				__UpperCAmelCase		(		self     :Union[str, Any]      ,  lowercase__     :Tuple      ,  lowercase__     :int      ,  lowercase__     :List[str]      ,  lowercase__     :Dict      ,  lowercase__     :List[str]      ,  lowercase__     :List[Any]      ,  lowercase__     :List[str]      ,  lowercase__     :Any      ,  ):
										lowercase						   =       self.num_labels
										lowercase						   =       ElectraForSequenceClassification(__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  labels=__UpperCAmelCase    )
										self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.num_labels)    )

					def 				__UpperCAmelCase		(		self     :Dict      ,  lowercase__     :List[str]      ,  lowercase__     :Tuple      ,  lowercase__     :int      ,  lowercase__     :List[Any]      ,  lowercase__     :Optional[Any]      ,  lowercase__     :List[str]      ,  lowercase__     :int      ,  lowercase__     :List[Any]      ,  ):
										lowercase						   =       ElectraForQuestionAnswering(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       model(
										    __UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  start_positions=__UpperCAmelCase      ,  end_positions=__UpperCAmelCase      ,  )
										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     :Any      ,  lowercase__     :Dict      ,  lowercase__     :str      ,  lowercase__     :int      ,  lowercase__     :List[Any]      ,  lowercase__     :Optional[Any]      ,  lowercase__     :int      ,  lowercase__     :int      ,  lowercase__     :Dict      ,  ):
										lowercase						   =       self.num_choices
										lowercase						   =       ElectraForMultipleChoice(config=__UpperCAmelCase    )
										model.to(__UpperCAmelCase    )
										model.eval()
										lowercase						   =       input_ids.unsqueeze(1    ).expand(-1      ,  self.num_choices      ,  -1    ).contiguous()
										lowercase						   =       token_type_ids.unsqueeze(1    ).expand(-1      ,  self.num_choices      ,  -1    ).contiguous()
										lowercase						   =       input_mask.unsqueeze(1    ).expand(-1      ,  self.num_choices      ,  -1    ).contiguous()
										lowercase						   =       model(
										    __UpperCAmelCase      ,  attention_mask=__UpperCAmelCase      ,  token_type_ids=__UpperCAmelCase      ,  labels=__UpperCAmelCase      ,  )
										self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.num_choices)    )



					def 				__UpperCAmelCase		(		self     :List[str]    ):
										lowercase						   =       self.prepare_config_and_inputs()
										(
										    (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,      (
										    lowercase   
										)   ,         
										)						   =       config_and_inputs
										lowercase						   =       {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
										return config, inputs_dict




@require_torch
class 	a__       (       lowerCamelCase_  ,			lowerCamelCase_  ,			unittest.TestCase       ):


					"""simple docstring"""



					A__  :				Dict					 =				(
					    (
					        ElectraModel,
					        ElectraForPreTraining,
					        ElectraForMaskedLM,
					        ElectraForCausalLM,
					        ElectraForMultipleChoice,
					        ElectraForTokenClassification,
					        ElectraForSequenceClassification,
					        ElectraForQuestionAnswering,
					    )
					    if is_torch_available()
					    else ()
					)
					A__  :				str					 =				(
					    {
					        '''feature-extraction''': ElectraModel,
					        '''fill-mask''': ElectraForMaskedLM,
					        '''question-answering''': ElectraForQuestionAnswering,
					        '''text-classification''': ElectraForSequenceClassification,
					        '''text-generation''': ElectraForCausalLM,
					        '''token-classification''': ElectraForTokenClassification,
					        '''zero-shot''': ElectraForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)
					A__  :				List[str]					 =				True

					def 				__UpperCAmelCase		(		self     :int      ,  lowercase__     :List[str]      ,  lowercase__     :Union[str, Any]      ,  lowercase__     :Union[str, Any]=False    ):
										lowercase						   =       super()._prepare_for_class(__UpperCAmelCase      ,  __UpperCAmelCase      ,  return_labels=__UpperCAmelCase    )

										if return_labels:
															if model_class in get_values(__UpperCAmelCase    ):
																				lowercase						   =       torch.zeros(
																				    (self.model_tester.batch_size, self.model_tester.seq_length)      ,  dtype=torch.long      ,  device=__UpperCAmelCase    )
										return inputs_dict

					def 				__UpperCAmelCase		(		self     :str    ):
										lowercase						   =       ElectraModelTester(self    )
										lowercase						   =       ConfigTester(self      ,  config_class=__UpperCAmelCase      ,  hidden_size=37    )

					def 				__UpperCAmelCase		(		self     :List[str]    ):
										self.config_tester.run_common_tests()

					def 				__UpperCAmelCase		(		self     :str    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_model(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :List[Any]    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs_for_decoder()
										self.model_tester.create_and_check_electra_model_as_decoder(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :int    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										for type in ["absolute", "relative_key", "relative_key_query"]:
															lowercase						   =       type
															self.model_tester.create_and_check_electra_model(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :List[Any]    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_masked_lm(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :Optional[Any]    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_token_classification(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :Union[str, Any]    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_pretraining(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :int    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_sequence_classification(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :Optional[Any]    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_question_answering(*__UpperCAmelCase    )

					def 				__UpperCAmelCase		(		self     :Optional[int]    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_electra_for_multiple_choice(*__UpperCAmelCase    )

					@slow
					def 				__UpperCAmelCase		(		self     :int    ):



										for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															lowercase						   =       ElectraModel.from_pretrained(__UpperCAmelCase    )
															self.assertIsNotNone(__UpperCAmelCase    )



					def 				__UpperCAmelCase		(		self     :str    ):
										lowercase						   =       self.model_tester.prepare_config_and_inputs_for_decoder()
										self.model_tester.create_and_check_electra_for_causal_lm(*__UpperCAmelCase    )




@require_torch
class 	a__       (       unittest.TestCase       ):


					"""simple docstring"""



					@slow
					def 				__UpperCAmelCase		(		self     :Union[str, Any]    ):
										lowercase						   =       ElectraModel.from_pretrained('google/electra-small-discriminator'    )
										lowercase						   =       torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]    )
										lowercase						   =       torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]    )
										lowercase						   =       model(__UpperCAmelCase      ,  attention_mask=__UpperCAmelCase    )[0]
										lowercase						   =       torch.Size((1, 11, 256)    )
										self.assertEqual(output.shape      ,  __UpperCAmelCase    )
										lowercase						   =       torch.tensor(
										    [[[0.4471, 0.6821, -0.3265], [0.4627, 0.5255, -0.3668], [0.4532, 0.3313, -0.4344]]]    )

										self.assertTrue(torch.allclose(output[:, 1:4, 1:4]      ,  __UpperCAmelCase      ,  atol=1E-4    )    )












from functools import partial
from typing import Any, Callable, Dict, List, Type, TypeVar, Union, overload

import torch
import torch.nn as nn
import torch.types




def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			torch.Tensor:

			'''simple docstring'''


			if not inplace:
						UpperCamelCase_     				= ma + ma
			else:
						ma += ma

			return ma




def  a_		(							__snake_case     ,		__snake_case					)	->			torch.Tensor:

			'''simple docstring'''


			UpperCamelCase_     				= -1 * len(__snake_case					)
			UpperCamelCase_     				= list(range(len(tensor.shape[:zero_index]					)					)					)
			return tensor.permute(first_inds + [zero_index + i for i in inds]					)




def  a_		(							__snake_case     ,		__snake_case					)	->			torch.Tensor:

			'''simple docstring'''


			return t.reshape(t.shape[:-no_dims] + (-1,)					)




def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case     ,		__snake_case = 1E-4					)	->			torch.Tensor:

			'''simple docstring'''


			UpperCamelCase_     				= mask.expand(*value.shape					)
			return torch.sum(mask * value     ,		dim=__snake_case					) / (eps + torch.sum(__snake_case     ,		dim=__snake_case					))




def  a_		(							__snake_case     ,		__snake_case = 2.31_25     ,		__snake_case = 21.68_75     ,		__snake_case = 6_4					)	->			torch.Tensor:

			'''simple docstring'''


			UpperCamelCase_     				= torch.linspace(__snake_case     ,		__snake_case     ,		no_bins - 1     ,		device=pts.device					)
			UpperCamelCase_     				= torch.sqrt(torch.sum((pts.unsqueeze(-2					) - pts.unsqueeze(-3					)) ** 2     ,		dim=-1					)					)
			return torch.bucketize(__snake_case     ,		__snake_case					)




def  a_		(							__snake_case     ,		__snake_case					)	->			dict:

			'''simple docstring'''


			UpperCamelCase_     				= dicts[0]
			UpperCamelCase_     				= {}
			for k, v in first.items():
						UpperCamelCase_     				= [d[k] for d in dicts]
						if isinstance(__snake_case     ,		__snake_case					):
									UpperCamelCase_     				= dict_multimap(__snake_case     ,		__snake_case					)
						else:
									UpperCamelCase_     				= fn(__snake_case					)

			return new_dict




def  a_		(							__snake_case     ,		__snake_case					)	->			torch.Tensor:

			'''simple docstring'''


			UpperCamelCase_     				= v_bins.view(((1,) * len(x.shape					)) + (len(__snake_case					),)					)
			UpperCamelCase_     				= x[..., None] - reshaped_bins
			UpperCamelCase_     				= torch.argmin(torch.abs(__snake_case					)     ,		dim=-1					)
			return nn.functional.one_hot(__snake_case     ,		num_classes=len(__snake_case					)					).float()




def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case = 0     ,		__snake_case = 0					)	->			torch.Tensor:

			'''simple docstring'''


			UpperCamelCase_     				= []
			for i, s in enumerate(data.shape[:no_batch_dims]					):
						UpperCamelCase_     				= torch.arange(__snake_case					)
						UpperCamelCase_     				= r.view(*(*((1,) * i), -1, *((1,) * (len(inds.shape					) - i - 1)))					)
						ranges.append(__snake_case					)

			UpperCamelCase_     				= [slice(__snake_case					) for _ in range(len(data.shape					) - no_batch_dims					)]
			UpperCamelCase_     				= inds
			ranges.extend(__snake_case					)
			# Matt note: Editing this to get around the behaviour of using a list as an array index changing
			# in recent Numpy versions
			return data[tuple(__snake_case					)]


__a			:	List[Any]							     =		TypeVar("""T""")




def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			Dict[Any, Union[dict, list, tuple, Any]]:

			'''simple docstring'''


			UpperCamelCase_     				= {}
			for k, v in dic.items():
						if isinstance(__snake_case     ,		__snake_case					):
									UpperCamelCase_     				= dict_map(__snake_case     ,		__snake_case     ,		__snake_case					)
						else:
									UpperCamelCase_     				= tree_map(__snake_case     ,		__snake_case     ,		__snake_case					)

			return new_dict




@overload
def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			Any:

			'''simple docstring'''


			...




@overload
def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			dict:

			'''simple docstring'''


			...




@overload
def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			list:

			'''simple docstring'''


			...




@overload
def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			tuple:

			'''simple docstring'''


			...




def  a_		(							__snake_case     ,		__snake_case     ,		__snake_case					)	->			Any:

			'''simple docstring'''


			if isinstance(__snake_case     ,		__snake_case					):
						return dict_map(__snake_case     ,		__snake_case     ,		__snake_case					)
			elif isinstance(__snake_case     ,		__snake_case					):
						return [tree_map(__snake_case     ,		__snake_case     ,		__snake_case					) for x in tree]
			elif isinstance(__snake_case     ,		__snake_case					):
						return tuple(tree_map(__snake_case     ,		__snake_case     ,		__snake_case					) for x in tree					)
			elif isinstance(__snake_case     ,		__snake_case					):
						return fn(__snake_case					)
			else:
						print(type(__snake_case					)					)
						raise ValueError('Not supported'					)





__a			:	Tuple							     =		partial(tree_map, leaf_type=torch.Tensor)
