






"""simple docstring"""



import torch
from torch import nn





class 					_UpperCAmelCase       ( nn.Module							):




					def __init__(				self     :						int    ,						A     :						Union[str, Any]    ,						A     :						Optional[Any]    ,						A     :						Tuple    ,						A     :						Union[str, Any]    ,						A     :						Tuple=1    ,						A     :						List[str]=False   )  ->  Optional[Any]:
							super().__init__()

							lowercase_ : List[Any]							       =   n_token
							lowercase_ : Any							       =   d_embed
							lowercase_ : List[str]							       =   d_proj

							lowercase_ : Optional[Any]							       =   cutoffs + [n_token]
							lowercase_ : Tuple							       =   [0] + self.cutoffs
							lowercase_ : Tuple							       =   div_val

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

							if self.n_clusters > 0:
									lowercase_ : List[Any]							       =   nn.Parameter(torch.zeros(self.n_clusters    ,						self.d_embed   )   )
									lowercase_ : List[Any]							       =   nn.Parameter(torch.zeros(self.n_clusters   )   )

							lowercase_ : List[str]							       =   nn.ModuleList()
							lowercase_ : Union[str, Any]							       =   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(A    ,						A   )   )   )
											else:
													self.out_projs.append(A   )

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

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

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

							lowercase_ : Dict							       =   keep_order




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

							return logit




					def   A  (				self     :						Union[str, Any]    ,						A     :						Optional[int]    ,						A     :						Dict=None    ,						A     :						Dict=False   )  ->  int:

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

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

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

											weights.append(A   )
											biases.append(A   )

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

									lowercase_ : List[Any]							       =   self._compute_logit(A    ,						A    ,						A    ,						A   )
									lowercase_ : Tuple							       =   nn.functional.log_softmax(A    ,						dim=1   )

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

									lowercase_ : int							       =   0
									lowercase_ : List[Any]							       =   [0] + self.cutoffs
									for i in range(len(A   ) - 1   ):
											lowercase_       ,					lowercase_ : int							       =   cutoff_values[i], cutoff_values[i + 1]

											if labels is not None:
													lowercase_ : Dict							       =   (labels >= l_idx) & (labels < r_idx)
													lowercase_ : Optional[Any]							       =   mask_i.nonzero().squeeze()

													if indices_i.numel() == 0:
															continue

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

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

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

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

							return out






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

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

											weights.append(A   )
											biases.append(A   )

									lowercase_       ,					lowercase_       ,					lowercase_ : str							       =   weights[0], biases[0], self.out_projs[0]
									lowercase_ : List[str]							       =   self._compute_logit(A    ,						A    ,						A    ,						A   )

									lowercase_ : Dict							       =   hidden.new_empty((head_logit.size(0   ), self.n_token)   )
									lowercase_ : Tuple							       =   nn.functional.log_softmax(A    ,						dim=1   )

									lowercase_ : Optional[Any]							       =   [0] + self.cutoffs
									for i in range(len(A   ) - 1   ):
											lowercase_       ,					lowercase_ : Dict							       =   cutoff_values[i], cutoff_values[i + 1]

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

													lowercase_ : List[str]							       =   self._compute_logit(A    ,						A    ,						A    ,						A   )
													lowercase_ : Dict							       =   nn.functional.log_softmax(A    ,						dim=1   )

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

									return out





"""simple docstring"""





from __future__ import annotations



def       lowerCamelCase__		(			__snake_case,     __snake_case	)							->		float:


					"""simple docstring"""





					_UpperCamelCase							 =  sorted(numsa + numsa	)
					_UpperCamelCase ,  _UpperCamelCase							 =  divmod(len(__snake_case	),     2	)
					if mod == 1:
										return all_numbers[div]
					else:
										return (all_numbers[div] + all_numbers[div - 1]) / 2


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				_a														=		[float(x) for x in input("""Enter the elements of first array: """).split()]
				_a														=		[float(x) for x in input("""Enter the elements of second array: """).split()]
				print(F"""The median of two arrays is: {median_of_two_arrays(array_a, array_a)}""")






