



"""simple docstring"""







import copy
import inspect
import unittest

from transformers import AutoBackbone
from transformers.configuration_utils import PretrainedConfig
from transformers.testing_utils import require_timm, require_torch, torch_device
from transformers.utils.import_utils import is_torch_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor


if is_torch_available():
							import torch

							from transformers import TimmBackbone, TimmBackboneConfig

from ...test_pipeline_mixin import PipelineTesterMixin
class        __A       :







		'''simple docstring'''





		def __init__(	self						:  Dict			,_snake_case						:  Dict			,_snake_case						:  str=None			,_snake_case						:  Optional[Any]=None			,_snake_case						:  Union[str, Any]=None			,_snake_case						:  Dict="resnet50"			,_snake_case						:  Dict=3			,_snake_case						:  Union[str, Any]=32			,_snake_case						:  int=3			,_snake_case						:  List[Any]=True			,_snake_case						:  Optional[int]=True			,)					->		Any:






				"""simple docstring"""



				lowercase__   :    Optional[int]				=			parent
				lowercase__   :    List[str]				=			out_indices if out_indices is not None else [4]
				lowercase__   :    Optional[int]				=			stage_names
				lowercase__   :    Optional[int]				=			out_features
				lowercase__   :    int				=			backbone
				lowercase__   :    List[str]				=			batch_size
				lowercase__   :    List[str]				=			image_size
				lowercase__   :    int				=			num_channels
				lowercase__   :    Any				=			use_pretrained_backbone
				lowercase__   :    Any				=			is_training







		def 					UpperCAmelCase    (	self						:  int						)					->		Dict:






				"""simple docstring"""



				lowercase__   :    List[Any]				=			floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)
				lowercase__   :    Union[str, Any]				=			self.get_config()

				return config, pixel_values







		def 					UpperCAmelCase    (	self						:  List[str]						)					->		str:






				"""simple docstring"""



				return TimmBackboneConfig(
				    image_size=self.image_size			,num_channels=self.num_channels			,out_features=self.out_features			,out_indices=self.out_indices			,stage_names=self.stage_names			,use_pretrained_backbone=self.use_pretrained_backbone			,backbone=self.backbone			,)







		def 					UpperCAmelCase    (	self						:  str			,_snake_case						:  Any			,_snake_case						:  List[str]						)					->		Any:






				"""simple docstring"""



				lowercase__   :    List[Any]				=			TimmBackbone(config=_snake_case						)
				model.to(_snake_case						)
				model.eval()
				with torch.no_grad():
						lowercase__   :    str				=			model(_snake_case						)
				self.parent.assertEqual(
				    result.feature_map[-1].shape			,(self.batch_size, model.channels[-1], 14, 14)			,)







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Optional[Any]:






				"""simple docstring"""



				lowercase__   :    List[str]				=			self.prepare_config_and_inputs()
				lowercase__		,			lowercase__   :    str				=			config_and_inputs
				lowercase__   :    str				=			{'''pixel_values''': pixel_values}
				return config, inputs_dict





@require_torch
@require_timm
class        __A       (	A_     ,A_     ,A_     ,unittest.TestCase    ):







		'''simple docstring'''





		lowerCAmelCase			:					Optional[Any]   	=				(TimmBackbone,) if is_torch_available() else ()
		lowerCAmelCase			:					List[Any]   	=				{"feature-extraction": TimmBackbone} if is_torch_available() else {}
		lowerCAmelCase			:					int   	=				False
		lowerCAmelCase			:					List[str]   	=				False
		lowerCAmelCase			:					Tuple   	=				False
		lowerCAmelCase			:					int   	=				False







		def 					UpperCAmelCase    (	self						:  Any						)					->		int:






				"""simple docstring"""



				lowercase__   :    Optional[Any]				=			TimmBackboneModelTester(self						)
				lowercase__   :    Optional[Any]				=			ConfigTester(self			,config_class=_snake_case			,has_text_modality=_snake_case						)







		def 					UpperCAmelCase    (	self						:  Union[str, Any]						)					->		List[Any]:






				"""simple docstring"""



				self.config_tester.create_and_test_config_to_json_string()
				self.config_tester.create_and_test_config_to_json_file()
				self.config_tester.create_and_test_config_from_and_save_pretrained()
				self.config_tester.create_and_test_config_with_num_labels()
				self.config_tester.check_config_can_be_init_without_params()
				self.config_tester.check_config_arguments_init()







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Union[str, Any]:






				"""simple docstring"""



				lowercase__   :    str				=			'''resnet18'''
				lowercase__   :    List[Any]				=			'''microsoft/resnet-18'''

				lowercase__   :    str				=			AutoBackbone.from_pretrained(_snake_case			,use_timm_backbone=_snake_case						)
				lowercase__   :    List[str]				=			AutoBackbone.from_pretrained(_snake_case						)

				self.assertEqual(len(timm_model.out_features						)			,len(transformers_model.out_features						)						)
				self.assertEqual(len(timm_model.stage_names						)			,len(transformers_model.stage_names						)						)
				self.assertEqual(timm_model.channels			,transformers_model.channels						)
				# Out indices are set to the last layer by default. For timm models, we don't know
				# the number of layers in advance, so we set it to (-1,), whereas for transformers
				# models, we set it to [len(stage_names) - 1] (kept for backward compatibility).
				self.assertEqual(timm_model.out_indices			,(-1,)						)
				self.assertEqual(transformers_model.out_indices			,[len(timm_model.stage_names						) - 1]						)

				lowercase__   :    Optional[Any]				=			AutoBackbone.from_pretrained(_snake_case			,use_timm_backbone=_snake_case			,out_indices=[1, 2, 3]						)
				lowercase__   :    int				=			AutoBackbone.from_pretrained(_snake_case			,out_indices=[1, 2, 3]						)

				self.assertEqual(timm_model.out_indices			,transformers_model.out_indices						)
				self.assertEqual(len(timm_model.out_features						)			,len(transformers_model.out_features						)						)
				self.assertEqual(timm_model.channels			,transformers_model.channels						)







		@unittest.skip('''TimmBackbone doesn\'t support feed forward chunking'''						)
		def 					UpperCAmelCase    (	self						:  Tuple						)					->		Union[str, Any]:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone doesn\'t have num_hidden_layers attribute'''						)
		def 					UpperCAmelCase    (	self						:  Union[str, Any]						)					->		Dict:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone initialization is managed on the timm side'''						)
		def 					UpperCAmelCase    (	self						:  str						)					->		List[Any]:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone models doesn\'t have inputs_embeds'''						)
		def 					UpperCAmelCase    (	self						:  int						)					->		Any:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone models doesn\'t have inputs_embeds'''						)
		def 					UpperCAmelCase    (	self						:  str						)					->		List[Any]:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone model cannot be created without specifying a backbone checkpoint'''						)
		def 					UpperCAmelCase    (	self						:  str						)					->		int:






				"""simple docstring"""



				pass







		@unittest.skip('''Only checkpoints on timm can be loaded into TimmBackbone'''						)
		def 					UpperCAmelCase    (	self						:  Tuple						)					->		Tuple:






				"""simple docstring"""



				pass







		@unittest.skip('''model weights aren\'t tied in TimmBackbone.'''						)
		def 					UpperCAmelCase    (	self						:  Any						)					->		int:






				"""simple docstring"""



				pass







		@unittest.skip('''model weights aren\'t tied in TimmBackbone.'''						)
		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Any:






				"""simple docstring"""



				pass







		@unittest.skip('''Only checkpoints on timm can be loaded into TimmBackbone'''						)
		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Tuple:






				"""simple docstring"""



				pass







		@unittest.skip('''Only checkpoints on timm can be loaded into TimmBackbone'''						)
		def 					UpperCAmelCase    (	self						:  Union[str, Any]						)					->		Any:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone doesn\'t have hidden size info in its configuration.'''						)
		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Union[str, Any]:






				"""simple docstring"""



				pass







		@unittest.skip('''TimmBackbone doesn\'t support output_attentions.'''						)
		def 					UpperCAmelCase    (	self						:  Union[str, Any]						)					->		Union[str, Any]:






				"""simple docstring"""



				pass







		@unittest.skip('''Safetensors is not supported by timm.'''						)
		def 					UpperCAmelCase    (	self						:  int						)					->		Optional[int]:






				"""simple docstring"""



				pass







		@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''						)
		def 					UpperCAmelCase    (	self						:  List[Any]						)					->		int:






				"""simple docstring"""



				pass







		def 					UpperCAmelCase    (	self						:  List[str]						)					->		Optional[Any]:






				"""simple docstring"""



				lowercase__		,			lowercase__   :    Union[str, Any]				=			self.model_tester.prepare_config_and_inputs_for_common()

				for model_class in self.all_model_classes:
						lowercase__   :    str				=			model_class(_snake_case						)
						lowercase__   :    Optional[int]				=			inspect.signature(model.forward						)
						# signature.parameters is an OrderedDict => so arg_names order is deterministic
						lowercase__   :    Optional[int]				=			[*signature.parameters.keys()]

						lowercase__   :    Union[str, Any]				=			['''pixel_values''']
						self.assertListEqual(arg_names[:1]			,_snake_case						)







		def 					UpperCAmelCase    (	self						:  Any						)					->		Optional[Any]:






				"""simple docstring"""



				lowercase__		,			lowercase__   :    Union[str, Any]				=			self.model_tester.prepare_config_and_inputs_for_common()
				lowercase__   :    int				=			True
				lowercase__   :    List[Any]				=			self.has_attentions

				# no need to test all models as different heads yield the same functionality
				lowercase__   :    Union[str, Any]				=			self.all_model_classes[0]
				lowercase__   :    Optional[int]				=			model_class(_snake_case						)
				model.to(_snake_case						)

				lowercase__   :    List[str]				=			self._prepare_for_class(_snake_case			,_snake_case						)
				lowercase__   :    Optional[Any]				=			model(**_snake_case						)
				lowercase__   :    Optional[int]				=			outputs[0][-1]

				# Encoder-/Decoder-only models
				lowercase__   :    Optional[Any]				=			outputs.hidden_states[0]
				hidden_states.retain_grad()

				if self.has_attentions:
						lowercase__   :    str				=			outputs.attentions[0]
						attentions.retain_grad()

				output.flatten()[0].backward(retain_graph=_snake_case						)

				self.assertIsNotNone(hidden_states.grad						)

				if self.has_attentions:
						self.assertIsNotNone(attentions.grad						)







		def 					UpperCAmelCase    (	self						:  Optional[Any]						)					->		Optional[int]:






				"""simple docstring"""



				lowercase__		,			lowercase__   :    Optional[Any]				=			self.model_tester.prepare_config_and_inputs_for_common()

				for model_class in self.all_model_classes:
						lowercase__   :    Tuple				=			model_class(_snake_case						)
						model.to(_snake_case						)
						model.eval()
						lowercase__   :    Optional[Any]				=			model(**_snake_case						)

						self.assertEqual(len(result.feature_maps						)			,len(config.out_indices						)						)
						self.assertEqual(len(model.channels						)			,len(config.out_indices						)						)

						# Check output of last stage is taken if out_features=None, out_indices=None
						lowercase__   :    Optional[int]				=			copy.deepcopy(_snake_case						)
						lowercase__   :    Union[str, Any]				=			None
						lowercase__   :    Optional[int]				=			model_class(_snake_case						)
						model.to(_snake_case						)
						model.eval()
						lowercase__   :    Any				=			model(**_snake_case						)

						self.assertEqual(len(result.feature_maps						)			,1						)
						self.assertEqual(len(model.channels						)			,1						)

						# Check backbone can be initialized with fresh weights
						lowercase__   :    List[Any]				=			copy.deepcopy(_snake_case						)
						lowercase__   :    List[Any]				=			False
						lowercase__   :    Dict				=			model_class(_snake_case						)
						model.to(_snake_case						)
						model.eval()
						lowercase__   :    List[str]				=			model(**_snake_case						)




"""simple docstring"""



def   __lowerCAmelCase						(						)	->						Union[str, Any]:


    """simple docstring"""





    snake_case    :      Dict      					=    []
    snake_case    :      List[Any]      					=    1

    while len(lowercase ) < 1e6:
        constant.append(str(lowercase ) )
        i += 1

    snake_case    :      Tuple      					=    "".join(lowercase )

    return (
        int(constant[0] )
        * int(constant[9] )
        * int(constant[99] )
        * int(constant[999] )
        * int(constant[9999] )
        * int(constant[9_9999] )
        * int(constant[99_9999] )
    )


if __name__ == "__main__":
  print(solution())





