


'''simple docstring'''






import torch
import torch.nn.functional as F

from diffusers import VQDiffusionScheduler

from .test_schedulers import SchedulerCommonTest




class 		a__				(							a__  ):





							'''simple docstring'''






							lowercase__			:   Any							=      (VQDiffusionScheduler,)







							def   __SCREAMING_SNAKE_CASE							(		self					,    **lowerCamelCase_   )       ->							Dict:
														lowerCAmelCase__          =	{
														    '''num_vec_classes''': 40_97,
														    '''num_train_timesteps''': 1_00,
														}

														config.update(**lowerCamelCase_   )
														return config







							def   __SCREAMING_SNAKE_CASE							(		self					,    lowerCamelCase_   )       ->							int:
														lowerCAmelCase__          =	4
														lowerCAmelCase__          =	8
														lowerCAmelCase__          =	8

														lowerCAmelCase__          =	torch.randint(0					,    lowerCamelCase_					,    (batch_size, height * width)   )

														return sample







							@property
							def   __SCREAMING_SNAKE_CASE							(		self   )       ->							Tuple:
														assert False







							def   __SCREAMING_SNAKE_CASE							(		self					,    lowerCamelCase_   )       ->							Optional[int]:
														def model(lowerCamelCase_					,    lowerCamelCase_					,    *lowerCamelCase_   ):
																					lowerCAmelCase__   ,					lowerCAmelCase__          =	sample.shape
																					lowerCAmelCase__          =	torch.rand((batch_size, num_vec_classes - 1, num_latent_pixels)   )
																					lowerCAmelCase__          =	F.log_softmax(logits.double()					,    dim=1   ).float()
																					return return_value

														return model







							def   __SCREAMING_SNAKE_CASE							(		self   )       ->							Optional[int]:
														for timesteps in [2, 5, 1_00, 10_00]:
																					self.check_over_configs(num_train_timesteps=lowerCamelCase_   )







							def   __SCREAMING_SNAKE_CASE							(		self   )       ->							List[Any]:
														for num_vec_classes in [5, 1_00, 10_00, 40_00]:
																					self.check_over_configs(num_vec_classes=lowerCamelCase_   )







							def   __SCREAMING_SNAKE_CASE							(		self   )       ->							Any:
														for t in [0, 50, 99]:
																					self.check_over_forward(time_step=lowerCamelCase_   )







							def   __SCREAMING_SNAKE_CASE							(		self   )       ->							Any:
														pass



'''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