


'''simple docstring'''

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


a_  :				Optional[Any]						= logging.get_logger(__name__)

a_  :				List[str]						= {
    """shi-labs/nat-mini-in1k-224""": """https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json""",
    # See all Nat models at https://huggingface.co/models?filter=nat
}





class      snake_case    (    lowercase			,						lowercase			):





  """simple docstring"""




  _lowerCamelCase		    =  "nat"

  _lowerCamelCase		    =  {
      "num_attention_heads": "num_heads",
      "num_hidden_layers": "num_layers",
  }






  def __init__(    self			,  UpperCamelCase=4			,  UpperCamelCase=3			,  UpperCamelCase=64			,  UpperCamelCase=[3, 4, 6, 5]			,  UpperCamelCase=[2, 4, 8, 16]			,  UpperCamelCase=7			,  UpperCamelCase=3.0			,  UpperCamelCase=True			,  UpperCamelCase=0.0			,  UpperCamelCase=0.0			,  UpperCamelCase=0.1			,  UpperCamelCase="gelu"			,  UpperCamelCase=0.02			,  UpperCamelCase=1e-5			,  UpperCamelCase=0.0			,  UpperCamelCase=None			,  UpperCamelCase=None			,  **UpperCamelCase			,  ):







   """simple docstring"""
   super().__init__(**UpperCamelCase     )

   lowerCamelCase_      =  patch_size
   lowerCamelCase_      =  num_channels
   lowerCamelCase_      =  embed_dim
   lowerCamelCase_      =  depths
   lowerCamelCase_      =  len(UpperCamelCase     )
   lowerCamelCase_      =  num_heads
   lowerCamelCase_      =  kernel_size
   lowerCamelCase_      =  mlp_ratio
   lowerCamelCase_      =  qkv_bias
   lowerCamelCase_      =  hidden_dropout_prob
   lowerCamelCase_      =  attention_probs_dropout_prob
   lowerCamelCase_      =  drop_path_rate
   lowerCamelCase_      =  hidden_act
   lowerCamelCase_      =  layer_norm_eps
   lowerCamelCase_      =  initializer_range
   # we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
   # this indicates the channel dimension after the last stage of the model
   lowerCamelCase_      =  int(embed_dim * 2 ** (len(UpperCamelCase     ) - 1)     )
   lowerCamelCase_      =  layer_scale_init_value
   lowerCamelCase_      =  ["stem"] + [f'''stage{idx}''' for idx in range(1			,  len(UpperCamelCase     ) + 1     )]
   lowerCamelCase_ ,lowerCamelCase_      =  get_aligned_output_features_output_indices(
       out_features=UpperCamelCase			,  out_indices=UpperCamelCase			,  stage_names=self.stage_names     )




"""simple docstring"""


from math import pow






def 			__UpperCAmelCase    (	lowercase      ,lowercase      ,lowercase      ,lowercase      ,lowercase      ,):







  """simple docstring"""
  if current_sum == needed_sum:
    # If the sum of the powers is equal to needed_sum, then we have a solution.
    solutions_count += 1
    return current_sum, solutions_count

  _UpperCAmelCase         =					int(pow(lowercase      ,lowercase						)						)
  if current_sum + i_to_n <= needed_sum:
    # If the sum of the powers is less than needed_sum, then continue adding powers.
    current_sum += i_to_n
    _UpperCAmelCase       , _UpperCAmelCase         =					backtrack(
        lowercase      ,lowercase      ,current_number + 1      ,lowercase      ,lowercase						)
    current_sum -= i_to_n
  if i_to_n < needed_sum:
    # If the power of i is less than needed_sum, then try with the next power.
    _UpperCAmelCase       , _UpperCAmelCase         =					backtrack(
        lowercase      ,lowercase      ,current_number + 1      ,lowercase      ,lowercase						)
  return current_sum, solutions_count






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  if not (1 <= needed_sum <= 10_00 and 2 <= power <= 10):
    raise ValueError(
        """Invalid input\n"""
        """needed_sum must be between 1 and 1000, power between 2 and 10."""						)

  return backtrack(lowercase      ,lowercase      ,1      ,0      ,0						)[1]  # Return the solutions_count


if __name__ == "__main__":
    import doctest

    doctest.testmod()
