


'''simple docstring'''


import torch
from torch import nn





class        lowercase__    (		nn.Module   ):





							'''simple docstring'''


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

											_SCREAMING_SNAKE_CASE					:			Dict							= n_token
											_SCREAMING_SNAKE_CASE					:			Optional[int]							= d_embed
											_SCREAMING_SNAKE_CASE					:			Optional[int]							= d_proj

											_SCREAMING_SNAKE_CASE					:			List[str]							= cutoffs + [n_token]
											_SCREAMING_SNAKE_CASE					:			List[Any]							= [0] + self.cutoffs
											_SCREAMING_SNAKE_CASE					:			int							= div_val

											_SCREAMING_SNAKE_CASE					:			List[Any]							= self.cutoffs[0]
											_SCREAMING_SNAKE_CASE					:			Optional[Any]							= len(self.cutoffs    ) - 1
											_SCREAMING_SNAKE_CASE					:			Any							= self.shortlist_size + self.n_clusters

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

											_SCREAMING_SNAKE_CASE					:			Tuple							= nn.ModuleList()
											_SCREAMING_SNAKE_CASE					:			int							= 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					:			List[str]							= self.cutoff_ends[i], self.cutoff_ends[i + 1]
																			_SCREAMING_SNAKE_CASE					:			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					:			Dict							= keep_order






							def UpperCAmelCase_      (       self       ,   __snake_case       ,   __snake_case       ,   __snake_case       ,   __snake_case    ):
											if proj is None:
															_SCREAMING_SNAKE_CASE					:			List[Any]							= nn.functional.linear(__snake_case       ,   __snake_case       ,   bias=__snake_case    )
											else:
															# if CUDA_MAJOR <= 9 and CUDA_MINOR <= 1:
															_SCREAMING_SNAKE_CASE					:			List[str]							= nn.functional.linear(__snake_case       ,   proj.t().contiguous()    )
															_SCREAMING_SNAKE_CASE					:			Tuple							= 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 UpperCAmelCase_      (       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					:			int							= labels[..., 1:].contiguous()
															_SCREAMING_SNAKE_CASE					:			List[str]							= hidden.view(-1       ,   hidden.size(-1    )    )
															_SCREAMING_SNAKE_CASE					:			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					:			Tuple							= hidden.view(-1       ,   hidden.size(-1    )    )

											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]    )
															if labels is not None:
																			_SCREAMING_SNAKE_CASE					:			Optional[int]							= labels != -100
																			_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= torch.zeros_like(__snake_case       ,   dtype=hidden.dtype       ,   device=hidden.device    )
																			_SCREAMING_SNAKE_CASE					:			List[Any]							= (
																			    -nn.functional.log_softmax(__snake_case       ,   dim=-1    )[mask].gather(1       ,   labels[mask].unsqueeze(1    )    ).squeeze(1    )
																			)
															else:
																			_SCREAMING_SNAKE_CASE					:			List[Any]							= nn.functional.log_softmax(__snake_case       ,   dim=-1    )
											else:
															# construct weights and biases
															_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE					:			Union[str, 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					:			List[str]							= self.out_layers[0].weight[l_idx:r_idx]
																							_SCREAMING_SNAKE_CASE					:			Dict							= self.out_layers[0].bias[l_idx:r_idx]
																			else:
																							_SCREAMING_SNAKE_CASE					:			Optional[Any]							= self.out_layers[i].weight
																							_SCREAMING_SNAKE_CASE					:			Tuple							= self.out_layers[i].bias

																			if i == 0:
																							_SCREAMING_SNAKE_CASE					:			Optional[Any]							= torch.cat([weight_i, self.cluster_weight]       ,   dim=0    )
																							_SCREAMING_SNAKE_CASE					:			Optional[int]							= 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					:			Union[str, Any]							= weights[0], biases[0], self.out_projs[0]

															_SCREAMING_SNAKE_CASE					:			Tuple							= self._compute_logit(__snake_case       ,   __snake_case       ,   __snake_case       ,   __snake_case    )
															_SCREAMING_SNAKE_CASE					:			Optional[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					:			int							= torch.zeros_like(__snake_case       ,   dtype=hidden.dtype       ,   device=hidden.device    )

															_SCREAMING_SNAKE_CASE					:			Tuple							= 0
															_SCREAMING_SNAKE_CASE					:			List[str]							= [0] + self.cutoffs
															for i in range(len(__snake_case    ) - 1    ):
																			_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE					:			int							= cutoff_values[i], cutoff_values[i + 1]

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

																							if indices_i.numel() == 0:
																											continue

																							_SCREAMING_SNAKE_CASE					:			Optional[int]							= labels.index_select(0       ,   __snake_case    ) - l_idx
																							_SCREAMING_SNAKE_CASE					:			Any							= head_logprob.index_select(0       ,   __snake_case    )
																							_SCREAMING_SNAKE_CASE					:			Optional[int]							= hidden.index_select(0       ,   __snake_case    )
																			else:
																							_SCREAMING_SNAKE_CASE					:			List[str]							= hidden

																			if i == 0:
																							if labels is not None:
																											_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= head_logprob_i.gather(1       ,   target_i[:, None]    ).squeeze(1    )
																							else:
																											_SCREAMING_SNAKE_CASE					:			Optional[Any]							= head_logprob[:, : self.cutoffs[0]]
																			else:
																							_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= 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					:			List[Any]							= nn.functional.log_softmax(__snake_case       ,   dim=1    )
																							_SCREAMING_SNAKE_CASE					:			List[str]							= self.cutoffs[0] + i - 1  # No probability for the head cluster
																							if labels is not None:
																											_SCREAMING_SNAKE_CASE					:			List[str]							= head_logprob_i[:, cluster_prob_idx] + tail_logprob_i.gather(
																											    1       ,   target_i[:, None]    ).squeeze(1    )
																							else:
																											_SCREAMING_SNAKE_CASE					:			str							= head_logprob[:, cluster_prob_idx, None] + tail_logprob_i
																											_SCREAMING_SNAKE_CASE					:			List[Any]							= 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 UpperCAmelCase_      (       self       ,   __snake_case    ):
											if self.n_clusters == 0:
															_SCREAMING_SNAKE_CASE					:			int							= 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					:			List[Any]							= [], []
															for i in range(len(self.cutoffs    )    ):
																			if self.div_val == 1:
																							_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE					:			List[str]							= self.cutoff_ends[i], self.cutoff_ends[i + 1]
																							_SCREAMING_SNAKE_CASE					:			int							= self.out_layers[0].weight[l_idx:r_idx]
																							_SCREAMING_SNAKE_CASE					:			str							= self.out_layers[0].bias[l_idx:r_idx]
																			else:
																							_SCREAMING_SNAKE_CASE					:			Dict							= self.out_layers[i].weight
																							_SCREAMING_SNAKE_CASE					:			int							= self.out_layers[i].bias

																			if i == 0:
																							_SCREAMING_SNAKE_CASE					:			List[Any]							= torch.cat([weight_i, self.cluster_weight]       ,   dim=0    )
																							_SCREAMING_SNAKE_CASE					:			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					:			Tuple							= weights[0], biases[0], self.out_projs[0]
															_SCREAMING_SNAKE_CASE					:			int							= self._compute_logit(__snake_case       ,   __snake_case       ,   __snake_case       ,   __snake_case    )

															_SCREAMING_SNAKE_CASE					:			int							= hidden.new_empty((head_logit.size(0    ), self.n_token)    )
															_SCREAMING_SNAKE_CASE					:			List[Any]							= nn.functional.log_softmax(__snake_case       ,   dim=1    )

															_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= [0] + self.cutoffs
															for i in range(len(__snake_case    ) - 1    ):
																			_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE					:			Optional[int]							= cutoff_values[i], cutoff_values[i + 1]

																			if i == 0:
																							_SCREAMING_SNAKE_CASE					:			Tuple							= head_logprob[:, : self.cutoffs[0]]
																			else:
																							_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE						,			_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= 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					:			Optional[int]							= nn.functional.log_softmax(__snake_case       ,   dim=1    )

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

															return out








'''simple docstring'''


import argparse
import datetime







def      snake_case_  (    SCREAMING_SNAKE_CASE__	):







				"""simple docstring"""





				_SCREAMING_SNAKE_CASE					:			Optional[int]							= {
				    """0""": """Sunday""",
				    """1""": """Monday""",
				    """2""": """Tuesday""",
				    """3""": """Wednesday""",
				    """4""": """Thursday""",
				    """5""": """Friday""",
				    """6""": """Saturday""",
				}

				_SCREAMING_SNAKE_CASE					:			Optional[int]							= {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

				# Validate
				if not 0 < len(SCREAMING_SNAKE_CASE__	) < 11:
								raise ValueError("""Must be 10 characters long"""	)

				# Get month
				_SCREAMING_SNAKE_CASE					:			int							= int(date_input[0] + date_input[1]	)
				# Validate
				if not 0 < m < 13:
								raise ValueError("""Month must be between 1 - 12"""	)

				_SCREAMING_SNAKE_CASE					:			str							= date_input[2]
				# Validate
				if sep_a not in ["-", "/"]:
								raise ValueError("""Date separator must be '-' or '/'"""	)

				# Get day
				_SCREAMING_SNAKE_CASE					:			int							= int(date_input[3] + date_input[4]	)
				# Validate
				if not 0 < d < 32:
								raise ValueError("""Date must be between 1 - 31"""	)

				# Get second separator
				_SCREAMING_SNAKE_CASE					:			str							= date_input[5]
				# Validate
				if sep_a not in ["-", "/"]:
								raise ValueError("""Date separator must be '-' or '/'"""	)

				# Get year
				_SCREAMING_SNAKE_CASE					:			int							= int(date_input[6] + date_input[7] + date_input[8] + date_input[9]	)
				# Arbitrary year range
				if not 45 < y < 8500:
								raise ValueError(
								    """Year out of range. There has to be some sort of limit...right?"""	)

				# Get datetime obj for validation
				_SCREAMING_SNAKE_CASE					:			Optional[int]							= datetime.date(int(SCREAMING_SNAKE_CASE__	)				, int(SCREAMING_SNAKE_CASE__	)				, int(SCREAMING_SNAKE_CASE__	)	)

				# Start math
				if m <= 2:
								_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= y - 1
								_SCREAMING_SNAKE_CASE					:			Optional[int]							= m + 12
				# maths var
				_SCREAMING_SNAKE_CASE					:			int							= int(str(SCREAMING_SNAKE_CASE__	)[:2]	)
				_SCREAMING_SNAKE_CASE					:			int							= int(str(SCREAMING_SNAKE_CASE__	)[2:]	)
				_SCREAMING_SNAKE_CASE					:			int							= int(2.6 * m - 5.3_9	)
				_SCREAMING_SNAKE_CASE					:			int							= int(c / 4	)
				_SCREAMING_SNAKE_CASE					:			int							= int(k / 4	)
				_SCREAMING_SNAKE_CASE					:			int							= int(d + k	)
				_SCREAMING_SNAKE_CASE					:			int							= int(t + u + v + x	)
				_SCREAMING_SNAKE_CASE					:			int							= int(z - (2 * c)	)
				_SCREAMING_SNAKE_CASE					:			int							= round(w % 7	)
				# End math

				# Validate math
				if f != convert_datetime_days[dt_ck.weekday()]:
								raise AssertionError("""The date was evaluated incorrectly. Contact developer."""	)

				# Response
				_SCREAMING_SNAKE_CASE					:			str							= f"""Your date {date_input}, is a {days[str(SCREAMING_SNAKE_CASE__	)]}!"""
				return response


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				UpperCAmelCase_						:  Tuple				  =						argparse.ArgumentParser(
				    description=(
				        'Find out what day of the week nearly any date is or was. Enter '
				        'date as a string in the mm-dd-yyyy or mm/dd/yyyy format'
				    )
				)
				parser.add_argument(
				    'date_input', type=str, help='Date as a string (mm-dd-yyyy or mm/dd/yyyy)'
				)
				UpperCAmelCase_						:  List[Any]				  =						parser.parse_args()
				zeller(args.date_input)




