
'''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 	a_	(_a				,      _a     ):
       __lowerCAmelCase     :					List[Any]     =   """pixel_values"""
       __lowerCAmelCase     :					Dict     =   False
       __lowerCAmelCase     :					Tuple     =   TimmBackboneConfig




       def __init__(  self , snake_case_ , **snake_case_	):
         requires_backends(self , """timm"""	)
         super().__init__(__lowercase	)
         _lowerCAmelCase							:	int 					=       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(__lowercase , """out_features"""	) and config.out_features is not None:
           raise ValueError("""out_features is not supported by TimmBackbone. Please use out_indices instead."""	)

         _lowerCAmelCase							:	int 					=       getattr(__lowercase , """use_pretrained_backbone""" , __lowercase	)
         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							:	int 					=       config.out_indices if getattr(__lowercase , """out_indices""" , __lowercase	) is not None else (-1,)

         _lowerCAmelCase							:	Optional[int] 					=       timm.create_model(
             config.backbone , pretrained=__lowercase , features_only=config.features_only , in_chans=config.num_channels , out_indices=__lowercase , **__lowercase , )
         # 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							:	Tuple 					=       {layer["""module"""]: str(__lowercase	) for i, layer in enumerate(self._backbone.feature_info.info	)}
         super()._init_backbone(__lowercase	)




       @classmethod
       def 				__UpperCamelCase							(  cls , snake_case_ , *snake_case_ , **snake_case_	):
         requires_backends(cls , ["""vision""", """timm"""]	)
         from ...models.timm_backbone import TimmBackboneConfig

         _lowerCAmelCase							:	str 					=       kwargs.pop("""config""" , TimmBackboneConfig()	)

         _lowerCAmelCase							:	List[str] 					=       kwargs.pop("""use_timm_backbone""" , __lowercase	)
         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							:	List[Any] 					=       kwargs.pop("""features_only""" , config.features_only	)
         _lowerCAmelCase							:	Tuple 					=       kwargs.pop("""use_pretrained_backbone""" , config.use_pretrained_backbone	)
         _lowerCAmelCase							:	Optional[Any] 					=       kwargs.pop("""out_indices""" , config.out_indices	)
         _lowerCAmelCase							:	Optional[int] 					=       TimmBackboneConfig(
             backbone=__lowercase , num_channels=__lowercase , features_only=__lowercase , use_pretrained_backbone=__lowercase , out_indices=__lowercase , )
         return super()._from_config(__lowercase , **__lowercase	)




       def 				__UpperCamelCase							(  self , snake_case_	):
         pass







       def 				__UpperCamelCase							(  self , snake_case_ , snake_case_=None , snake_case_=None , snake_case_=None , **snake_case_	):
         _lowerCAmelCase							:	Tuple 					=       return_dict if return_dict is not None else self.config.use_return_dict
         _lowerCAmelCase							:	Tuple 					=       (
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         _lowerCAmelCase							:	Union[str, 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							:	str 					=       self._all_layers
           _lowerCAmelCase							:	int 					=       self._backbone(__lowercase , **__lowercase	)
           _lowerCAmelCase							:	Tuple 					=       self._return_layers
           _lowerCAmelCase							:	List[Any] 					=       tuple(hidden_states[i] for i in self.out_indices	)
         else:
           _lowerCAmelCase							:	Optional[Any] 					=       self._backbone(__lowercase , **__lowercase	)
           _lowerCAmelCase							:	Union[str, Any] 					=       None

         _lowerCAmelCase							:	Optional[int] 					=       tuple(__lowercase	)
         _lowerCAmelCase							:	Union[str, Any] 					=       tuple(__lowercase	) if hidden_states is not None else None

         if not return_dict:
           _lowerCAmelCase							:	Tuple 					=       (feature_maps,)
           if output_hidden_states:
             _lowerCAmelCase							:	List[str] 					=       output + (hidden_states,)
           return output

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





'''simple docstring'''

from collections import defaultdict
from math import gcd

def 					__UpperCamelCase				(						lowercase__    :	int = 1_50_00_00			):






     '''simple docstring'''





     __lowercase      		=defaultdict(lowercase__			)
     __lowercase      		=2
     while 2 * euclid_m * (euclid_m + 1) <= limit:
          for euclid_n in range((euclid_m % 2) + 1,       lowercase__,       2			):
               if gcd(lowercase__,       lowercase__			) > 1:
                    continue
               __lowercase      		=2 * euclid_m * (euclid_m + euclid_n)
               for perimeter in range(lowercase__,       limit + 1,       lowercase__			):
                    frequencies[perimeter] += 1
          euclid_m += 1
     return sum(1 for frequency in frequencies.values() if frequency == 1			)


if __name__ == "__main__":
       print(F'''{solution() = }''')


