



'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase_  :							Tuple             =    {'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FNetConfig']}

try:
							if not is_sentencepiece_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase_  :							str             =    ['FNetTokenizer']

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase_  :							Optional[Any]             =    ['FNetTokenizerFast']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase_  :							Tuple             =    [
							    'FNET_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'FNetForMaskedLM',
							    'FNetForMultipleChoice',
							    'FNetForNextSentencePrediction',
							    'FNetForPreTraining',
							    'FNetForQuestionAnswering',
							    'FNetForSequenceClassification',
							    'FNetForTokenClassification',
							    'FNetLayer',
							    'FNetModel',
							    'FNetPreTrainedModel',
							]


if TYPE_CHECKING:
							from .configuration_fnet import FNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FNetConfig

							try:
														if not is_sentencepiece_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_fnet import FNetTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_fnet_fast import FNetTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_fnet import (
														    FNET_PRETRAINED_MODEL_ARCHIVE_LIST,
														    FNetForMaskedLM,
														    FNetForMultipleChoice,
														    FNetForNextSentencePrediction,
														    FNetForPreTraining,
														    FNetForQuestionAnswering,
														    FNetForSequenceClassification,
														    FNetForTokenClassification,
														    FNetLayer,
														    FNetModel,
														    FNetPreTrainedModel,
														)


else:
							import sys

							lowerCAmelCase_  :							Tuple             =    _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)









'''simple docstring'''



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

							SCREAMING_SNAKE_CASE       :   Tuple         =      int(pow(A       ,		A					)					)
							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
														SCREAMING_SNAKE_CASE       ,SCREAMING_SNAKE_CASE       :   Dict         =      backtrack(
														    A       ,		A       ,		current_number + 1       ,		A       ,		A					)
														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.
														SCREAMING_SNAKE_CASE       ,SCREAMING_SNAKE_CASE       :   int         =      backtrack(
														    A       ,		A       ,		current_number + 1       ,		A       ,		A					)
							return current_sum, solutions_count
def        UpperCAmelCase (    A	:					int       ,		A	:					int					):
							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(A       ,		A       ,		1       ,		0       ,		0					)[1]  # Return the solutions_count


if __name__ == "__main__":
							import doctest

							doctest.testmod()




