
'''simple docstring'''


from typing import Tuple, Union

from ...modeling_outputs import BackboneOutput
from ...modeling_utils import PreTrainedModel
from ...utils import is_timm_available, is_torch_available, requires_backends
from ...utils.backbone_utils import BackboneMixin
from .configuration_timm_backbone import TimmBackboneConfig


if is_timm_available():
					import timm


if is_torch_available():
					from torch import Tensor

class 	__lowercase				(  _lowercase      ,     _lowercase    ):
			lowerCamelCase			:		Any	      =			"pixel_values"
			lowerCamelCase			:		Tuple	      =			False
			lowerCamelCase			:		Tuple	      =			TimmBackboneConfig

			def __init__(self			,   A			,   **A      ):
								requires_backends(self			,   '''timm'''      )
								super().__init__(A      )
								lowerCamelCase_					:      Tuple     =		config

								if config.backbone is None:
													raise ValueError('''backbone is not set in the config. Please set it to a timm model name.'''      )

								if config.backbone not in timm.list_models():
													raise ValueError(F"""backbone {config.backbone} is not supported by timm."""      )

								if hasattr(A			,   '''out_features'''      ) and config.out_features is not None:
													raise ValueError('''out_features is not supported by TimmBackbone. Please use out_indices instead.'''      )

								lowerCamelCase_					:      List[Any]     =		getattr(A			,   '''use_pretrained_backbone'''			,   A      )
								if pretrained is None:
													raise ValueError('''use_pretrained_backbone is not set in the config. Please set it to True or False.'''      )

								# We just take the final layer by default. This matches the default for the transformers models.
								lowerCamelCase_					:      Any     =		config.out_indices if getattr(A			,   '''out_indices'''			,   A      ) is not None else (-1,)

								lowerCamelCase_					:      str     =		timm.create_model(
								    config.backbone			,   pretrained=A			,   features_only=config.features_only			,   in_chans=config.num_channels			,   out_indices=A			,   **A			,   )
								# These are used to control the output of the model when called. If output_hidden_states is True, then
								# return_layers is modified to include all layers.
								lowerCamelCase_					:      Optional[int]     =		self._backbone.return_layers
								lowerCamelCase_					:      Optional[Any]     =		{layer['''module''']: str(A      ) for i, layer in enumerate(self._backbone.feature_info.info      )}
								super()._init_backbone(A      )

			@classmethod
			def        UpperCAmelCase__ (cls			,   A			,   *A			,   **A      ):
								requires_backends(cls			,   ['''vision''', '''timm''']      )
								from ...models.timm_backbone import TimmBackboneConfig

								lowerCamelCase_					:      List[str]     =		kwargs.pop('''config'''			,   TimmBackboneConfig()      )

								lowerCamelCase_					:      List[str]     =		kwargs.pop('''use_timm_backbone'''			,   A      )
								if not use_timm:
													raise ValueError('''use_timm_backbone must be True for timm backbones'''      )

								lowerCamelCase_					:      List[Any]     =		kwargs.pop('''num_channels'''			,   config.num_channels      )
								lowerCamelCase_					:      Tuple     =		kwargs.pop('''features_only'''			,   config.features_only      )
								lowerCamelCase_					:      Union[str, Any]     =		kwargs.pop('''use_pretrained_backbone'''			,   config.use_pretrained_backbone      )
								lowerCamelCase_					:      List[str]     =		kwargs.pop('''out_indices'''			,   config.out_indices      )
								lowerCamelCase_					:      Any     =		TimmBackboneConfig(
								    backbone=A			,   num_channels=A			,   features_only=A			,   use_pretrained_backbone=A			,   out_indices=A			,   )
								return super()._from_config(A			,   **A      )

			def        UpperCAmelCase__ (self			,   A      ):
								pass






			def        UpperCAmelCase__ (self			,   A			,   A=None			,   A=None			,   A=None			,   **A      ):
								lowerCamelCase_					:      Tuple     =		return_dict if return_dict is not None else self.config.use_return_dict
								lowerCamelCase_					:      Dict     =		(
								    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
								)
								lowerCamelCase_					:      Optional[Any]     =		output_attentions if output_attentions is not None else self.config.output_attentions

								if output_attentions:
													raise ValueError('''Cannot output attentions for timm backbones at the moment'''      )

								if output_hidden_states:
													# We modify the return layers to include all the stages of the backbone
													lowerCamelCase_					:      Union[str, Any]     =		self._all_layers
													lowerCamelCase_					:      Any     =		self._backbone(A			,   **A      )
													lowerCamelCase_					:      Dict     =		self._return_layers
													lowerCamelCase_					:      List[Any]     =		tuple(hidden_states[i] for i in self.out_indices      )
								else:
													lowerCamelCase_					:      Optional[Any]     =		self._backbone(A			,   **A      )
													lowerCamelCase_					:      List[str]     =		None

								lowerCamelCase_					:      int     =		tuple(A      )
								lowerCamelCase_					:      Dict     =		tuple(A      ) if hidden_states is not None else None

								if not return_dict:
													lowerCamelCase_					:      List[Any]     =		(feature_maps,)
													if output_hidden_states:
																		lowerCamelCase_					:      Any     =		output + (hidden_states,)
													return output

								return BackboneOutput(feature_maps=A			,   hidden_states=A			,   attentions=A      )




'''simple docstring'''


import os
from math import logaa




def lowercase_	(   _lowercase = "base_exp.txt"				)     ->							int:
					'''simple docstring'''

					lowerCamelCase_					:      float     =		0
					lowerCamelCase_					:      Dict     =		0
					for i, line in enumerate(open(os.path.join(os.path.dirname(_lowercase				)			,       _lowercase				)				)				):
										lowerCamelCase_,      lowerCamelCase_					:      Dict     =		list(map(_lowercase			,       line.split(''','''				)				)				)
										if x * logaa(_lowercase				) > largest:
															lowerCamelCase_					:      List[str]     =		x * logaa(_lowercase				)
															lowerCamelCase_					:      Union[str, Any]     =		i + 1
					return result


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


