'''simple docstring'''

from math import pow
def 			__UpperCamelCase       (   UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase		,     ):
 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

 lowercase__				:    Optional[Any]  =					int(pow(UpperCAmelCase		,     UpperCAmelCase     )     )
 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
  lowercase__ ,							lowercase__				:    Dict  =					backtrack(
      UpperCAmelCase		,     UpperCAmelCase		,     current_number + 1		,     UpperCAmelCase		,     UpperCAmelCase     )
  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.
  lowercase__ ,							lowercase__				:    str  =					backtrack(
      UpperCAmelCase		,     UpperCAmelCase		,     current_number + 1		,     UpperCAmelCase		,     UpperCAmelCase     )
 return current_sum, solutions_count
def 			__UpperCamelCase       (   UpperCAmelCase		,     UpperCAmelCase     ):
 if not (1 <= needed_sum <= 1000 and 2 <= power <= 10):
  raise ValueError(
      '''Invalid input\n'''
      '''needed_sum must be between 1 and 1000, power between 2 and 10.'''     )

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


if __name__ == "__main__":
  import doctest

  doctest.testmod()


'''simple docstring'''

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a: List[str]          =   logging.get_logger(__name__)



class 			UpperCAmelCase  (						a__					):





       '''simple docstring'''



       SCREAMING_SNAKE_CASE							=    "encoder-decoder"
       SCREAMING_SNAKE_CASE							=    True

       def __init__(						self	,   **__lowerCAmelCase )  ->  int:
        super().__init__(**__lowerCAmelCase )
        assert (
            "encoder" in kwargs and "decoder" in kwargs
        ), "Config has to be initialized with encoder and decoder config"
        lowercase__				:    Optional[int]  =					kwargs.pop('''encoder''' )
        lowercase__				:    Union[str, Any]  =					encoder_config.pop('''model_type''' )
        lowercase__				:    Any  =					kwargs.pop('''decoder''' )
        lowercase__				:    Any  =					decoder_config.pop('''model_type''' )

        from ..auto.configuration_auto import AutoConfig

        lowercase__				:    Union[str, Any]  =					AutoConfig.for_model(__lowerCAmelCase	,   **__lowerCAmelCase )
        lowercase__				:    Optional[Any]  =					AutoConfig.for_model(__lowerCAmelCase	,   **__lowerCAmelCase )
        lowercase__				:    Tuple  =					True

       @classmethod
       def _lowerCAmelCase(						cls	,   __lowerCAmelCase	,   __lowerCAmelCase	,   **__lowerCAmelCase )  ->  PretrainedConfig:
        logger.info('''Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config''' )
        lowercase__				:    Union[str, Any]  =					True
        lowercase__				:    Any  =					True

        return cls(encoder=encoder_config.to_dict()	,   decoder=decoder_config.to_dict()	,   **__lowerCAmelCase )


       def _lowerCAmelCase(						self )  ->  Any:
        lowercase__				:    Any  =					copy.deepcopy(self.__dict__ )
        lowercase__				:    Optional[Any]  =					self.encoder.to_dict()
        lowercase__				:    Tuple  =					self.decoder.to_dict()
        lowercase__				:    Dict  =					self.__class__.model_type
        return output

