


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


UpperCAmelCase__   	=							logging.get_logger(__name__)

UpperCAmelCase__   	=							{
    '''microsoft/focalnet-tiny''': '''https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json''',
}







class       lowerCamelCase__   (       lowerCAmelCase   ,							lowerCAmelCase):
     SCREAMING_SNAKE_CASE__      			=			'''focalnet'''





     def __init__(self		,     UpperCAmelCase=2_2_4		,     UpperCAmelCase=4		,     UpperCAmelCase=3		,     UpperCAmelCase=9_6		,     UpperCAmelCase=False		,     UpperCAmelCase=[1_9_2, 3_8_4, 7_6_8, 7_6_8]		,     UpperCAmelCase=[2, 2, 6, 2]		,     UpperCAmelCase=[2, 2, 2, 2]		,     UpperCAmelCase=[3, 3, 3, 3]		,     UpperCAmelCase="gelu"		,     UpperCAmelCase=4.0		,     UpperCAmelCase=0.0		,     UpperCAmelCase=0.1		,     UpperCAmelCase=False		,     UpperCAmelCase=1e-4		,     UpperCAmelCase=False		,     UpperCAmelCase=False		,     UpperCAmelCase=False		,     UpperCAmelCase=0.02		,     UpperCAmelCase=1e-5		,     UpperCAmelCase=3_2		,     UpperCAmelCase=None		,     UpperCAmelCase=None		,     **UpperCAmelCase		,     )     ->   Dict:
      super().__init__(**UpperCAmelCase       )

      _lowercase							      =image_size
      _lowercase							      =patch_size
      _lowercase							      =num_channels
      _lowercase							      =embed_dim
      _lowercase							      =use_conv_embed
      _lowercase							      =hidden_sizes
      _lowercase							      =depths
      _lowercase							      =focal_levels
      _lowercase							      =focal_windows
      _lowercase							      =hidden_act
      _lowercase							      =mlp_ratio
      _lowercase							      =hidden_dropout_prob
      _lowercase							      =drop_path_rate
      _lowercase							      =use_layerscale
      _lowercase							      =layerscale_value
      _lowercase							      =use_post_layernorm
      _lowercase							      =use_post_layernorm_in_modulation
      _lowercase							      =normalize_modulator
      _lowercase							      =initializer_range
      _lowercase							      =layer_norm_eps
      _lowercase							      =encoder_stride
      _lowercase							      =['''stem'''] + [f"stage{idx}" for idx in range(1		,     len(self.depths       ) + 1       )]
      _lowercase      ,    _lowercase							      =get_aligned_output_features_output_indices(
          out_features=UpperCAmelCase		,     out_indices=UpperCAmelCase		,     stage_names=self.stage_names       )








def lowerCamelCase__    (							snake_case_	:  int       )      ->				int:
   if not isinstance(snake_case_       ,      snake_case_       ) or number < 0:
      raise ValueError('''Input must be a non-negative integer'''       )

   __snake_case							       =   0
   while number:
      # This way we arrive at next set bit (next 1) instead of looping
      # through each bit and checking for 1s hence the
      # loop won't run 32 times it will only run the number of `1` times
      number &= number - 1
      count += 1
   return count


if __name__ == "__main__":
    import doctest

    doctest.testmod()

