


'''simple docstring'''






from typing import TYPE_CHECKING

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


__UpperCAmelCase    				=							{
    '''configuration_switch_transformers''': [
        '''SWITCH_TRANSFORMERS_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''SwitchTransformersConfig''',
        '''SwitchTransformersOnnxConfig''',
    ]
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__UpperCAmelCase    				=							[
		    '''SWITCH_TRANSFORMERS_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''SwitchTransformersEncoderModel''',
		    '''SwitchTransformersForConditionalGeneration''',
		    '''SwitchTransformersModel''',
		    '''SwitchTransformersPreTrainedModel''',
		    '''SwitchTransformersTop1Router''',
		    '''SwitchTransformersSparseMLP''',
		]


if TYPE_CHECKING:
		from .configuration_switch_transformers import (
		    SWITCH_TRANSFORMERS_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    SwitchTransformersConfig,
		    SwitchTransformersOnnxConfig,
		)

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_switch_transformers import (
				    SWITCH_TRANSFORMERS_PRETRAINED_MODEL_ARCHIVE_LIST,
				    SwitchTransformersEncoderModel,
				    SwitchTransformersForConditionalGeneration,
				    SwitchTransformersModel,
				    SwitchTransformersPreTrainedModel,
				    SwitchTransformersSparseMLP,
				    SwitchTransformersTopaRouter,
				)


else:
		import sys

		__UpperCAmelCase    				=							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



'''simple docstring'''






from .hash_table import HashTable
from .number_theory.prime_numbers import is_prime, next_prime




class 		a__				(							a__  ):





							'''simple docstring'''






							def __init__(		self					,    *lowerCamelCase_					,    **lowerCamelCase_   )       ->							Optional[int]:
														super().__init__(*lowerCamelCase_					,    **lowerCamelCase_   )







							def   __SCREAMING_SNAKE_CASE							(		self					,    lowerCamelCase_					,    lowerCamelCase_   )       ->							Optional[int]:
														lowerCAmelCase__          =	(
														    next_prime(value % self.size_table   )
														    if not is_prime(value % self.size_table   )
														    else value % self.size_table
														)  # gt = bigger than
														return next_prime_gt - (data % next_prime_gt)







							def   __SCREAMING_SNAKE_CASE							(		self					,    lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_   )       ->							Optional[int]:
														return (increment * self.__hash_function_a(lowerCamelCase_					,    lowerCamelCase_   )) % self.size_table







							def   __SCREAMING_SNAKE_CASE							(		self					,    lowerCamelCase_					,    lowerCamelCase_=None   )       ->							Any:
														lowerCAmelCase__          =	1
														lowerCAmelCase__          =	self.hash_function(lowerCamelCase_   )

														while self.values[new_key] is not None and self.values[new_key] != key:
																					lowerCAmelCase__          =	(
																					    self.__hash_double_function(lowerCamelCase_					,    lowerCamelCase_					,    lowerCamelCase_   )
																					    if self.balanced_factor() >= self.lim_charge
																					    else None
																					)
																					if new_key is None:
																												break
																					else:
																												i += 1

														return new_key