




import torch
from torch import nn







class 				lowerCAmelCase_       (					nn.Module							):






				def __init__(			self      ,snake_case__      ,snake_case__      ,snake_case__      ,snake_case__      ,snake_case__=1      ,snake_case__=False ):
							super().__init__()

							SCREAMING_SNAKE_CASE_   : Any					  =      n_token
							SCREAMING_SNAKE_CASE_   : Tuple					  =      d_embed
							SCREAMING_SNAKE_CASE_   : int					  =      d_proj

							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      cutoffs + [n_token]
							SCREAMING_SNAKE_CASE_   : Dict					  =      [0] + self.cutoffs
							SCREAMING_SNAKE_CASE_   : int					  =      div_val

							SCREAMING_SNAKE_CASE_   : Tuple					  =      self.cutoffs[0]
							SCREAMING_SNAKE_CASE_   : str					  =      len(self.cutoffs ) - 1
							SCREAMING_SNAKE_CASE_   : Any					  =      self.shortlist_size + self.n_clusters

							if self.n_clusters > 0:
										SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      nn.Parameter(torch.zeros(self.n_clusters      ,self.d_embed ) )
										SCREAMING_SNAKE_CASE_   : int					  =      nn.Parameter(torch.zeros(self.n_clusters ) )

							SCREAMING_SNAKE_CASE_   : int					  =      nn.ModuleList()
							SCREAMING_SNAKE_CASE_   : List[str]					  =      nn.ParameterList()

							if div_val == 1:
										for i in range(len(self.cutoffs ) ):
													if d_proj != d_embed:
																self.out_projs.append(nn.Parameter(torch.FloatTensor(snake_case__      ,snake_case__ ) ) )
													else:
																self.out_projs.append(snake_case__ )

										self.out_layers.append(nn.Linear(snake_case__      ,snake_case__ ) )
							else:
										for i in range(len(self.cutoffs ) ):
													SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Tuple					  =      self.cutoff_ends[i], self.cutoff_ends[i + 1]
													SCREAMING_SNAKE_CASE_   : List[str]					  =      d_embed // (div_val**i)

													self.out_projs.append(nn.Parameter(torch.FloatTensor(snake_case__      ,snake_case__ ) ) )

													self.out_layers.append(nn.Linear(snake_case__      ,r_idx - l_idx ) )

							SCREAMING_SNAKE_CASE_   : Any					  =      keep_order






				def 		snake_case	(			self      ,snake_case__      ,snake_case__      ,snake_case__      ,snake_case__ ):
							if proj is None:
										SCREAMING_SNAKE_CASE_   : List[str]					  =      nn.functional.linear(snake_case__      ,snake_case__      ,bias=snake_case__ )
							else:
										# if CUDA_MAJOR <= 9 and CUDA_MINOR <= 1:
										SCREAMING_SNAKE_CASE_   : int					  =      nn.functional.linear(snake_case__      ,proj.t().contiguous() )
										SCREAMING_SNAKE_CASE_   : Any					  =      nn.functional.linear(snake_case__      ,snake_case__      ,bias=snake_case__ )
										# else:
										#     logit = torch.einsum('bd,de,ev->bv', (hidden, proj, weight.t()))
										#     if bias is not None:
										#         logit = logit + bias

							return logit






				def 		snake_case	(			self      ,snake_case__      ,snake_case__=None      ,snake_case__=False ):

							if labels is not None:
										# Shift so that tokens < n predict n
										SCREAMING_SNAKE_CASE_   : Dict					  =      hidden[..., :-1, :].contiguous()
										SCREAMING_SNAKE_CASE_   : Optional[int]					  =      labels[..., 1:].contiguous()
										SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      hidden.view(-1      ,hidden.size(-1 ) )
										SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      labels.view(-1 )
										if hidden.size(0 ) != labels.size(0 ):
													raise RuntimeError('Input and labels should have the same size in the batch dimension.' )
							else:
										SCREAMING_SNAKE_CASE_   : List[Any]					  =      hidden.view(-1      ,hidden.size(-1 ) )

							if self.n_clusters == 0:
										SCREAMING_SNAKE_CASE_   : str					  =      self._compute_logit(snake_case__      ,self.out_layers[0].weight      ,self.out_layers[0].bias      ,self.out_projs[0] )
										if labels is not None:
													SCREAMING_SNAKE_CASE_   : Tuple					  =      labels != -100
													SCREAMING_SNAKE_CASE_   : Optional[int]					  =      torch.zeros_like(snake_case__      ,dtype=hidden.dtype      ,device=hidden.device )
													SCREAMING_SNAKE_CASE_   : int					  =      (
													    -nn.functional.log_softmax(snake_case__      ,dim=-1 )[mask].gather(1      ,labels[mask].unsqueeze(1 ) ).squeeze(1 )
													)
										else:
													SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      nn.functional.log_softmax(snake_case__      ,dim=-1 )
							else:
										# construct weights and biases
										SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : List[str]					  =      [], []
										for i in range(len(self.cutoffs ) ):
													if self.div_val == 1:
																SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Dict					  =      self.cutoff_ends[i], self.cutoff_ends[i + 1]
																SCREAMING_SNAKE_CASE_   : Any					  =      self.out_layers[0].weight[l_idx:r_idx]
																SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self.out_layers[0].bias[l_idx:r_idx]
													else:
																SCREAMING_SNAKE_CASE_   : List[Any]					  =      self.out_layers[i].weight
																SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      self.out_layers[i].bias

													if i == 0:
																SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      torch.cat([weight_i, self.cluster_weight]      ,dim=0 )
																SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      torch.cat([bias_i, self.cluster_bias]      ,dim=0 )

													weights.append(snake_case__ )
													biases.append(snake_case__ )

										SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Any					  =      weights[0], biases[0], self.out_projs[0]

										SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self._compute_logit(snake_case__      ,snake_case__      ,snake_case__      ,snake_case__ )
										SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      nn.functional.log_softmax(snake_case__      ,dim=1 )

										if labels is None:
													SCREAMING_SNAKE_CASE_   : Any					  =      hidden.new_empty((head_logit.size(0 ), self.n_token) )
										else:
													SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      torch.zeros_like(snake_case__      ,dtype=hidden.dtype      ,device=hidden.device )

										SCREAMING_SNAKE_CASE_   : List[str]					  =      0
										SCREAMING_SNAKE_CASE_   : str					  =      [0] + self.cutoffs
										for i in range(len(snake_case__ ) - 1 ):
													SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      cutoff_values[i], cutoff_values[i + 1]

													if labels is not None:
																SCREAMING_SNAKE_CASE_   : List[str]					  =      (labels >= l_idx) & (labels < r_idx)
																SCREAMING_SNAKE_CASE_   : Tuple					  =      mask_i.nonzero().squeeze()

																if indices_i.numel() == 0:
																			continue

																SCREAMING_SNAKE_CASE_   : Any					  =      labels.index_select(0      ,snake_case__ ) - l_idx
																SCREAMING_SNAKE_CASE_   : List[str]					  =      head_logprob.index_select(0      ,snake_case__ )
																SCREAMING_SNAKE_CASE_   : Any					  =      hidden.index_select(0      ,snake_case__ )
													else:
																SCREAMING_SNAKE_CASE_   : Any					  =      hidden

													if i == 0:
																if labels is not None:
																			SCREAMING_SNAKE_CASE_   : List[str]					  =      head_logprob_i.gather(1      ,target_i[:, None] ).squeeze(1 )
																else:
																			SCREAMING_SNAKE_CASE_   : Any					  =      head_logprob[:, : self.cutoffs[0]]
													else:
																SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Dict					  =      weights[i], biases[i], self.out_projs[i]

																SCREAMING_SNAKE_CASE_   : int					  =      self._compute_logit(snake_case__      ,snake_case__      ,snake_case__      ,snake_case__ )
																SCREAMING_SNAKE_CASE_   : List[str]					  =      nn.functional.log_softmax(snake_case__      ,dim=1 )
																SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self.cutoffs[0] + i - 1  # No probability for the head cluster
																if labels is not None:
																			SCREAMING_SNAKE_CASE_   : List[Any]					  =      head_logprob_i[:, cluster_prob_idx] + tail_logprob_i.gather(
																			    1      ,target_i[:, None] ).squeeze(1 )
																else:
																			SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      head_logprob[:, cluster_prob_idx, None] + tail_logprob_i
																			SCREAMING_SNAKE_CASE_   : Dict					  =      logprob_i

													if labels is not None:
																if (hasattr(self      ,'keep_order' ) and self.keep_order) or keep_order:
																			out.index_copy_(0      ,snake_case__      ,-logprob_i )
																else:
																			out[offset : offset + logprob_i.size(0 )].copy_(-logprob_i )
																offset += logprob_i.size(0 )

							return out






				def 		snake_case	(			self      ,snake_case__ ):
							if self.n_clusters == 0:
										SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      self._compute_logit(snake_case__      ,self.out_layers[0].weight      ,self.out_layers[0].bias      ,self.out_projs[0] )
										return nn.functional.log_softmax(snake_case__      ,dim=-1 )
							else:
										# construct weights and biases
										SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      [], []
										for i in range(len(self.cutoffs ) ):
													if self.div_val == 1:
																SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      self.cutoff_ends[i], self.cutoff_ends[i + 1]
																SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self.out_layers[0].weight[l_idx:r_idx]
																SCREAMING_SNAKE_CASE_   : int					  =      self.out_layers[0].bias[l_idx:r_idx]
													else:
																SCREAMING_SNAKE_CASE_   : Any					  =      self.out_layers[i].weight
																SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      self.out_layers[i].bias

													if i == 0:
																SCREAMING_SNAKE_CASE_   : str					  =      torch.cat([weight_i, self.cluster_weight]      ,dim=0 )
																SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      torch.cat([bias_i, self.cluster_bias]      ,dim=0 )

													weights.append(snake_case__ )
													biases.append(snake_case__ )

										SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : List[str]					  =      weights[0], biases[0], self.out_projs[0]
										SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self._compute_logit(snake_case__      ,snake_case__      ,snake_case__      ,snake_case__ )

										SCREAMING_SNAKE_CASE_   : Tuple					  =      hidden.new_empty((head_logit.size(0 ), self.n_token) )
										SCREAMING_SNAKE_CASE_   : str					  =      nn.functional.log_softmax(snake_case__      ,dim=1 )

										SCREAMING_SNAKE_CASE_   : Any					  =      [0] + self.cutoffs
										for i in range(len(snake_case__ ) - 1 ):
													SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : List[str]					  =      cutoff_values[i], cutoff_values[i + 1]

													if i == 0:
																SCREAMING_SNAKE_CASE_   : List[Any]					  =      head_logprob[:, : self.cutoffs[0]]
													else:
																SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : List[str]					  =      weights[i], biases[i], self.out_projs[i]

																SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self._compute_logit(snake_case__      ,snake_case__      ,snake_case__      ,snake_case__ )
																SCREAMING_SNAKE_CASE_   : int					  =      nn.functional.log_softmax(snake_case__      ,dim=1 )

																SCREAMING_SNAKE_CASE_   : Any					  =      head_logprob[:, -i] + tail_logprob_i
																SCREAMING_SNAKE_CASE_   : Dict					  =      logprob_i

										return out









from __future__ import annotations

import math


def 					_a							(					lowerCAmelCase )->	bool:

		if 1 < number < 4:
				# 2 and 3 are primes
				return True
		elif number < 2 or number % 2 == 0 or number % 3 == 0:
				# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
				return False

		# All primes number are in format of 6k +/- 1
		for i in range(5    ,						int(math.sqrt(lowerCAmelCase ) + 1 )    ,						6 ):
				if number % i == 0 or number % (i + 2) == 0:
						return False
		return True


SCREAMING_SNAKE_CASE:     List[str]									= [num for num in range(3, 1_0_0_0_0_1, 2) if not is_prime(num)]


def 					_a							(					lowerCAmelCase )->	list[int]:
		if not isinstance(lowerCAmelCase    ,						lowerCAmelCase ):
				raise ValueError('n must be an integer' )
		if n <= 0:
				raise ValueError('n must be >= 0' )

		SCREAMING_SNAKE_CASE_					      =							[]
		for num in range(len(lowerCAmelCase ) ):
				SCREAMING_SNAKE_CASE_					      =							0
				while 2 * i * i <= odd_composites[num]:
						SCREAMING_SNAKE_CASE_					      =							odd_composites[num] - 2 * i * i
						if is_prime(lowerCAmelCase ):
								break
						i += 1
				else:
						list_nums.append(odd_composites[num] )
						if len(lowerCAmelCase ) == n:
								return list_nums

		return []


def 					_a							(					)->	int:
		return compute_nums(1 )[0]


if __name__ == "__main__":
						print(f"""{solution() = }""")