
"""simple docstring"""




from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


A__      :	str          =    logging.get_logger(__name__)

A__      :	List[Any]          =    {
    """microsoft/resnet-50""": """https://huggingface.co/microsoft/resnet-50/blob/main/config.json""",
}







class   _lowercase						(       lowerCAmelCase_	,   lowerCAmelCase_				):


     '''simple docstring'''





     _A								=							'resnet'
     _A								=							['basic', 'bottleneck']



     def __init__(      self ,			__UpperCamelCase=3 ,			__UpperCamelCase=64 ,			__UpperCamelCase=[2_56, 5_12, 10_24, 20_48] ,			__UpperCamelCase=[3, 4, 6, 3] ,			__UpperCamelCase="bottleneck" ,			__UpperCamelCase="relu" ,			__UpperCamelCase=False ,			__UpperCamelCase=None ,			__UpperCamelCase=None ,			**__UpperCamelCase ,			)->					Union[str, Any]:
          super().__init__(**__UpperCamelCase  )
          if layer_type not in self.layer_types:
               raise ValueError(F"layer_type={layer_type} is not one of {','.join(self.layer_types  )}"  )
          UpperCAmelCase__							: List[str] 							=						num_channels
          UpperCAmelCase__							: str 							=						embedding_size
          UpperCAmelCase__							: Optional[int] 							=						hidden_sizes
          UpperCAmelCase__							: str 							=						depths
          UpperCAmelCase__							: Optional[int] 							=						layer_type
          UpperCAmelCase__							: str 							=						hidden_act
          UpperCAmelCase__							: Tuple 							=						downsample_in_first_stage
          UpperCAmelCase__							: str 							=						["stem"] + [F"stage{idx}" for idx in range(1 ,			len(__UpperCamelCase  ) + 1  )]
          UpperCAmelCase__							: Any 							=						get_aligned_output_features_output_indices(
              out_features=__UpperCamelCase ,			out_indices=__UpperCamelCase ,			stage_names=self.stage_names  )







class   _lowercase						(       lowerCAmelCase_				):


     '''simple docstring'''





     _A								=							version.parse('1.11'				)



     @property
     def  lowerCAmelCase__       (      self  )->					Mapping[str, Mapping[int, str]]:
          return OrderedDict(
              [
                  ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
              ]  )



     @property
     def  lowerCAmelCase__       (      self  )->					float:
          return 1E-3


"""simple docstring"""




from timeit import timeit



def 							a__ (				lowerCAmelCase	:       int		):






     '''simple docstring'''
     if number < 0:
          raise ValueError("the value of input must not be negative"		)
     UpperCAmelCase__							: Tuple 							=						0
     while number:
          number &= number - 1
          result += 1
     return result



def 							a__ (				lowerCAmelCase	:       int		):






     '''simple docstring'''
     if number < 0:
          raise ValueError("the value of input must not be negative"		)
     UpperCAmelCase__							: Union[str, Any] 							=						0
     while number:
          if number % 2 == 1:
               result += 1
          number >>= 1
     return result



def 							a__ (				):






     '''simple docstring'''

     def do_benchmark(lowerCAmelCase	:       int		) -> None:
          UpperCAmelCase__							: Dict 							=						"import __main__ as z"
          print(F"Benchmark when {number = }:"		)
          print(F"{get_set_bits_count_using_modulo_operator(lowerCAmelCase		) = }"		)
          UpperCAmelCase__							: Tuple 							=						timeit("z.get_set_bits_count_using_modulo_operator(25)"       ,    setup=lowerCAmelCase		)
          print(F"timeit() runs in {timing} seconds"		)
          print(F"{get_set_bits_count_using_brian_kernighans_algorithm(lowerCAmelCase		) = }"		)
          UpperCAmelCase__							: Any 							=						timeit(
              "z.get_set_bits_count_using_brian_kernighans_algorithm(25)"       ,    setup=lowerCAmelCase       ,    )
          print(F"timeit() runs in {timing} seconds"		)

     for number in (25, 37, 58, 0):
          do_benchmark(lowerCAmelCase		)
          print()


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()



