


"""simple docstring"""


import torch
from torch import nn



class   _a      (      nn.Module ):
    def __init__( self							:					Dict							,					SCREAMING_SNAKE_CASE__							:					int							,					SCREAMING_SNAKE_CASE__							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Optional[int]							,					SCREAMING_SNAKE_CASE__							:					List[str]=1							,					SCREAMING_SNAKE_CASE__							:					int=False				):
          super().__init__()

          lowerCamelCase__           =		n_token
          lowerCamelCase__           =		d_embed
          lowerCamelCase__           =		d_proj

          lowerCamelCase__           =		cutoffs + [n_token]
          lowerCamelCase__           =		[0] + self.cutoffs
          lowerCamelCase__           =		div_val

          lowerCamelCase__           =		self.cutoffs[0]
          lowerCamelCase__           =		len(self.cutoffs				) - 1
          lowerCamelCase__           =		self.shortlist_size + self.n_clusters

          if self.n_clusters > 0:
                lowerCamelCase__           =		nn.Parameter(torch.zeros(self.n_clusters							,					self.d_embed				)				)
                lowerCamelCase__           =		nn.Parameter(torch.zeros(self.n_clusters				)				)

          lowerCamelCase__           =		nn.ModuleList()
          lowerCamelCase__           =		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(lowerCAmelCase_							,					lowerCAmelCase_				)				)				)
                      else:
                            self.out_projs.append(lowerCAmelCase_				)

                self.out_layers.append(nn.Linear(lowerCAmelCase_							,					lowerCAmelCase_				)				)
          else:
                for i in range(len(self.cutoffs				)				):
                      lowerCamelCase__    ,  lowerCamelCase__           =		self.cutoff_ends[i], self.cutoff_ends[i + 1]
                      lowerCamelCase__           =		d_embed // (div_val**i)

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

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

          lowerCamelCase__           =		keep_order
    def      _UpperCamelCase       ( self							:					Optional[int]							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					Dict				):







          if proj is None:
                lowerCamelCase__           =		nn.functional.linear(lowerCAmelCase_							,					lowerCAmelCase_							,					bias=lowerCAmelCase_				)
          else:
                # if CUDA_MAJOR <= 9 and CUDA_MINOR <= 1:
                lowerCamelCase__           =		nn.functional.linear(lowerCAmelCase_							,					proj.t().contiguous()				)
                lowerCamelCase__           =		nn.functional.linear(lowerCAmelCase_							,					lowerCAmelCase_							,					bias=lowerCAmelCase_				)
                # else:
                #     logit = torch.einsum('bd,de,ev->bv', (hidden, proj, weight.t()))
                #     if bias is not None:
                #         logit = logit + bias

          return logit
    def      _UpperCamelCase       ( self							:					Optional[int]							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]=None							,					SCREAMING_SNAKE_CASE__							:					List[Any]=False				):







          if labels is not None:
                # Shift so that tokens < n predict n
                lowerCamelCase__           =		hidden[..., :-1, :].contiguous()
                lowerCamelCase__           =		labels[..., 1:].contiguous()
                lowerCamelCase__           =		hidden.view(-1							,					hidden.size(-1				)				)
                lowerCamelCase__           =		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:
                lowerCamelCase__           =		hidden.view(-1							,					hidden.size(-1				)				)

          if self.n_clusters == 0:
                lowerCamelCase__           =		self._compute_logit(lowerCAmelCase_							,					self.out_layers[0].weight							,					self.out_layers[0].bias							,					self.out_projs[0]				)
                if labels is not None:
                      lowerCamelCase__           =		labels != -1_00
                      lowerCamelCase__           =		torch.zeros_like(lowerCAmelCase_							,					dtype=hidden.dtype							,					device=hidden.device				)
                      lowerCamelCase__           =		(
                          -nn.functional.log_softmax(lowerCAmelCase_							,					dim=-1				)[mask].gather(1							,					labels[mask].unsqueeze(1				)				).squeeze(1				)
                      )
                else:
                      lowerCamelCase__           =		nn.functional.log_softmax(lowerCAmelCase_							,					dim=-1				)
          else:
                # construct weights and biases
                lowerCamelCase__    ,  lowerCamelCase__           =		[], []
                for i in range(len(self.cutoffs				)				):
                      if self.div_val == 1:
                            lowerCamelCase__    ,  lowerCamelCase__           =		self.cutoff_ends[i], self.cutoff_ends[i + 1]
                            lowerCamelCase__           =		self.out_layers[0].weight[l_idx:r_idx]
                            lowerCamelCase__           =		self.out_layers[0].bias[l_idx:r_idx]
                      else:
                            lowerCamelCase__           =		self.out_layers[i].weight
                            lowerCamelCase__           =		self.out_layers[i].bias

                      if i == 0:
                            lowerCamelCase__           =		torch.cat([weight_i, self.cluster_weight]							,					dim=0				)
                            lowerCamelCase__           =		torch.cat([bias_i, self.cluster_bias]							,					dim=0				)

                      weights.append(lowerCAmelCase_				)
                      biases.append(lowerCAmelCase_				)

                lowerCamelCase__    ,  lowerCamelCase__    ,  lowerCamelCase__           =		weights[0], biases[0], self.out_projs[0]

                lowerCamelCase__           =		self._compute_logit(lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_				)
                lowerCamelCase__           =		nn.functional.log_softmax(lowerCAmelCase_							,					dim=1				)

                if labels is None:
                      lowerCamelCase__           =		hidden.new_empty((head_logit.size(0				), self.n_token)				)
                else:
                      lowerCamelCase__           =		torch.zeros_like(lowerCAmelCase_							,					dtype=hidden.dtype							,					device=hidden.device				)

                lowerCamelCase__           =		0
                lowerCamelCase__           =		[0] + self.cutoffs
                for i in range(len(lowerCAmelCase_				) - 1				):
                      lowerCamelCase__    ,  lowerCamelCase__           =		cutoff_values[i], cutoff_values[i + 1]

                      if labels is not None:
                            lowerCamelCase__           =		(labels >= l_idx) & (labels < r_idx)
                            lowerCamelCase__           =		mask_i.nonzero().squeeze()

                            if indices_i.numel() == 0:
                                  continue

                            lowerCamelCase__           =		labels.index_select(0							,					lowerCAmelCase_				) - l_idx
                            lowerCamelCase__           =		head_logprob.index_select(0							,					lowerCAmelCase_				)
                            lowerCamelCase__           =		hidden.index_select(0							,					lowerCAmelCase_				)
                      else:
                            lowerCamelCase__           =		hidden

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

                            lowerCamelCase__           =		self._compute_logit(lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_				)
                            lowerCamelCase__           =		nn.functional.log_softmax(lowerCAmelCase_							,					dim=1				)
                            lowerCamelCase__           =		self.cutoffs[0] + i - 1  # No probability for the head cluster
                            if labels is not None:
                                  lowerCamelCase__           =		head_logprob_i[:, cluster_prob_idx] + tail_logprob_i.gather(
                                      1							,					target_i[:, None]				).squeeze(1				)
                            else:
                                  lowerCamelCase__           =		head_logprob[:, cluster_prob_idx, None] + tail_logprob_i
                                  lowerCamelCase__           =		logprob_i

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

          return out


    def      _UpperCamelCase       ( self							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					str				):







          if self.n_clusters == 0:
                lowerCamelCase__           =		self._compute_logit(lowerCAmelCase_							,					self.out_layers[0].weight							,					self.out_layers[0].bias							,					self.out_projs[0]				)
                return nn.functional.log_softmax(lowerCAmelCase_							,					dim=-1				)
          else:
                # construct weights and biases
                lowerCamelCase__    ,  lowerCamelCase__           =		[], []
                for i in range(len(self.cutoffs				)				):
                      if self.div_val == 1:
                            lowerCamelCase__    ,  lowerCamelCase__           =		self.cutoff_ends[i], self.cutoff_ends[i + 1]
                            lowerCamelCase__           =		self.out_layers[0].weight[l_idx:r_idx]
                            lowerCamelCase__           =		self.out_layers[0].bias[l_idx:r_idx]
                      else:
                            lowerCamelCase__           =		self.out_layers[i].weight
                            lowerCamelCase__           =		self.out_layers[i].bias

                      if i == 0:
                            lowerCamelCase__           =		torch.cat([weight_i, self.cluster_weight]							,					dim=0				)
                            lowerCamelCase__           =		torch.cat([bias_i, self.cluster_bias]							,					dim=0				)

                      weights.append(lowerCAmelCase_				)
                      biases.append(lowerCAmelCase_				)

                lowerCamelCase__    ,  lowerCamelCase__    ,  lowerCamelCase__           =		weights[0], biases[0], self.out_projs[0]
                lowerCamelCase__           =		self._compute_logit(lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_				)

                lowerCamelCase__           =		hidden.new_empty((head_logit.size(0				), self.n_token)				)
                lowerCamelCase__           =		nn.functional.log_softmax(lowerCAmelCase_							,					dim=1				)

                lowerCamelCase__           =		[0] + self.cutoffs
                for i in range(len(lowerCAmelCase_				) - 1				):
                      lowerCamelCase__    ,  lowerCamelCase__           =		cutoff_values[i], cutoff_values[i + 1]

                      if i == 0:
                            lowerCamelCase__           =		head_logprob[:, : self.cutoffs[0]]
                      else:
                            lowerCamelCase__    ,  lowerCamelCase__    ,  lowerCamelCase__           =		weights[i], biases[i], self.out_projs[i]

                            lowerCamelCase__           =		self._compute_logit(lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_							,					lowerCAmelCase_				)
                            lowerCamelCase__           =		nn.functional.log_softmax(lowerCAmelCase_							,					dim=1				)

                            lowerCamelCase__           =		head_logprob[:, -i] + tail_logprob_i
                            lowerCamelCase__           =		logprob_i

                return out







"""simple docstring"""


def   snake_case						(				_a:     int							)->		int:
      '''simple docstring'''


      lowerCamelCase__           =		1
      for i in range(1		,   num + 1							):
            fact *= i
      return fact



def   snake_case						(				_a:     int							)->		int:
      '''simple docstring'''


      lowerCamelCase__           =		0
      while number > 0:
            lowerCamelCase__           =		number % 10
            sum_of_digits += last_digit
            lowerCamelCase__           =		number // 10  # Removing the last_digit from the given number
      return sum_of_digits



def   snake_case						(				_a:     int = 100							)->		int:
      '''simple docstring'''


      lowerCamelCase__           =		factorial(_a							)
      lowerCamelCase__           =		split_and_add(_a							)
      return result


if __name__ == "__main__":
   print(solution(int(input("Enter the Number: ").strip())))



