

import itertools
import json
import linecache
import os
import pickle
import re
import socket
import string
from collections import Counter
from logging import getLogger
from pathlib import Path
from typing import Callable, Dict, Iterable, List

import git
import torch
from torch.utils.data import Dataset

from transformers import BartTokenizer, RagTokenizer, TaTokenizer


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__=True  ,		SCREAMING_SNAKE_CASE__="pt"       ):
						snake_case_   =	{'''add_prefix_space''': True} if isinstance(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ) and not line.startswith(''' '''       ) else {}
						snake_case_   =	padding_side
						return tokenizer(
						    [line]  ,		max_length=SCREAMING_SNAKE_CASE__  ,		padding='''max_length''' if pad_to_max_length else None  ,		truncation=SCREAMING_SNAKE_CASE__  ,		return_tensors=SCREAMING_SNAKE_CASE__  ,		add_special_tokens=SCREAMING_SNAKE_CASE__  ,		**SCREAMING_SNAKE_CASE__  ,		)


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__=None  ,		):
						snake_case_   =	input_ids.ne(SCREAMING_SNAKE_CASE__       ).any(dim=0       )
						if attention_mask is None:
												return input_ids[:, keep_column_mask]
						else:
												return (input_ids[:, keep_column_mask], attention_mask[:, keep_column_mask])





class 	snake_case_   (		__A					):







			'''simple docstring'''

			def __init__(     self :				List[Any]							,   _UpperCamelCase :				Any							,   _UpperCamelCase :				Optional[Any]							,   _UpperCamelCase :				Dict							,   _UpperCamelCase :				Optional[Any]							,   _UpperCamelCase :				Any="train"							,   _UpperCamelCase :				str=None							,   _UpperCamelCase :				Any=None							,   _UpperCamelCase :				Dict=None							,   _UpperCamelCase :				Tuple=""							,   )      ->Optional[Any]:
									super().__init__()
									snake_case_   =	Path(_UpperCamelCase							).joinpath(type_path + '''.source'''							)
									snake_case_   =	Path(_UpperCamelCase							).joinpath(type_path + '''.target'''							)
									snake_case_   =	self.get_char_lens(self.src_file							)
									snake_case_   =	max_source_length
									snake_case_   =	max_target_length
									assert min(self.src_lens							) > 0, f'''found empty line in {self.src_file}'''
									snake_case_   =	tokenizer
									snake_case_   =	prefix
									if n_obs is not None:
															snake_case_   =	self.src_lens[:n_obs]
									snake_case_   =	src_lang
									snake_case_   =	tgt_lang







			def __len__(     self :				List[Any]							)      ->str:
									return len(self.src_lens							)







			def __getitem__(     self :				List[str]							,   _UpperCamelCase :				Optional[Any]							)      ->Dict[str, torch.Tensor]:
									snake_case_   =	index + 1  # linecache starts at 1
									snake_case_   =	self.prefix + linecache.getline(str(self.src_file							)							,   _UpperCamelCase							).rstrip('''\n'''							)
									snake_case_   =	linecache.getline(str(self.tgt_file							)							,   _UpperCamelCase							).rstrip('''\n'''							)
									assert source_line, f'''empty source line for index {index}'''
									assert tgt_line, f'''empty tgt line for index {index}'''

									# Need to add eos token manually for T5
									if isinstance(self.tokenizer							,   _UpperCamelCase							):
															source_line += self.tokenizer.eos_token
															tgt_line += self.tokenizer.eos_token

									# Pad source and target to the right
									snake_case_   =	(
									    self.tokenizer.question_encoder if isinstance(self.tokenizer							,   _UpperCamelCase							) else self.tokenizer
									)
									snake_case_   =	self.tokenizer.generator if isinstance(self.tokenizer							,   _UpperCamelCase							) else self.tokenizer

									snake_case_   =	encode_line(_UpperCamelCase							,   _UpperCamelCase							,   self.max_source_length							,   '''right'''							)
									snake_case_   =	encode_line(_UpperCamelCase							,   _UpperCamelCase							,   self.max_target_length							,   '''right'''							)

									snake_case_   =	source_inputs['''input_ids'''].squeeze()
									snake_case_   =	target_inputs['''input_ids'''].squeeze()
									snake_case_   =	source_inputs['''attention_mask'''].squeeze()
									return {
									    "input_ids": source_ids,
									    "attention_mask": src_mask,
									    "decoder_input_ids": target_ids,
									}







			@staticmethod
			def 				snake_case__(     _UpperCamelCase :				str							)      ->Optional[Any]:
									return [len(_UpperCamelCase							) for x in Path(_UpperCamelCase							).open().readlines()]







			def 				snake_case__(     self :				List[Any]							,   _UpperCamelCase :				List[str]							)      ->Dict[str, torch.Tensor]:
									snake_case_   =	torch.stack([x['''input_ids'''] for x in batch]							)
									snake_case_   =	torch.stack([x['''attention_mask'''] for x in batch]							)
									snake_case_   =	torch.stack([x['''decoder_input_ids'''] for x in batch]							)
									snake_case_   =	(
									    self.tokenizer.generator.pad_token_id
									    if isinstance(self.tokenizer							,   _UpperCamelCase							)
									    else self.tokenizer.pad_token_id
									)
									snake_case_   =	(
									    self.tokenizer.question_encoder.pad_token_id
									    if isinstance(self.tokenizer							,   _UpperCamelCase							)
									    else self.tokenizer.pad_token_id
									)
									snake_case_   =	trim_batch(_UpperCamelCase							,   _UpperCamelCase							)
									snake_case_,    snake_case_   =	trim_batch(_UpperCamelCase							,   _UpperCamelCase							,   attention_mask=_UpperCamelCase							)
									snake_case_   =	{
									    '''input_ids''': source_ids,
									    '''attention_mask''': source_mask,
									    '''decoder_input_ids''': y,
									}
									return batch






lowerCAmelCase_       	=	getLogger(__name__)


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__       ):
						return list(itertools.chain.from_iterable(SCREAMING_SNAKE_CASE__       )       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__       ):
						snake_case_   =	get_git_info()
						save_json(SCREAMING_SNAKE_CASE__  ,		os.path.join(SCREAMING_SNAKE_CASE__  ,		'''git_log.json'''       )       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__=4  ,		**SCREAMING_SNAKE_CASE__       ):
						with open(SCREAMING_SNAKE_CASE__  ,		'''w'''       ) as f:
												json.dump(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		indent=SCREAMING_SNAKE_CASE__  ,		**SCREAMING_SNAKE_CASE__       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__       ):
						with open(SCREAMING_SNAKE_CASE__       ) as f:
												return json.load(SCREAMING_SNAKE_CASE__       )


def   __SCREAMING_SNAKE_CASE					():
						snake_case_   =	git.Repo(search_parent_directories=SCREAMING_SNAKE_CASE__       )
						snake_case_   =	{
						    '''repo_id''': str(SCREAMING_SNAKE_CASE__       ),
						    '''repo_sha''': str(repo.head.object.hexsha       ),
						    '''repo_branch''': str(repo.active_branch       ),
						    '''hostname''': str(socket.gethostname()       ),
						}
						return repo_infos


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						return list(map(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						with open(SCREAMING_SNAKE_CASE__  ,		'''wb'''       ) as f:
												return pickle.dump(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__       ):

						def remove_articles(SCREAMING_SNAKE_CASE__       ):
												return re.sub(R'''\b(a|an|the)\b'''  ,		''' '''  ,		SCREAMING_SNAKE_CASE__       )

						def white_space_fix(SCREAMING_SNAKE_CASE__       ):
												return " ".join(text.split()       )

						def remove_punc(SCREAMING_SNAKE_CASE__       ):
												snake_case_   =	set(string.punctuation       )
												return "".join(ch for ch in text if ch not in exclude       )

						def lower(SCREAMING_SNAKE_CASE__       ):
												return text.lower()

						return white_space_fix(remove_articles(remove_punc(lower(SCREAMING_SNAKE_CASE__       )       )       )       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						snake_case_   =	normalize_answer(SCREAMING_SNAKE_CASE__       ).split()
						snake_case_   =	normalize_answer(SCREAMING_SNAKE_CASE__       ).split()
						snake_case_   =	Counter(SCREAMING_SNAKE_CASE__       ) & Counter(SCREAMING_SNAKE_CASE__       )
						snake_case_   =	sum(common.values()       )
						if num_same == 0:
												return 0
						snake_case_   =	1.0 * num_same / len(SCREAMING_SNAKE_CASE__       )
						snake_case_   =	1.0 * num_same / len(SCREAMING_SNAKE_CASE__       )
						snake_case_   =	(2 * precision * recall) / (precision + recall)
						return fa


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						return normalize_answer(SCREAMING_SNAKE_CASE__       ) == normalize_answer(SCREAMING_SNAKE_CASE__       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						assert len(SCREAMING_SNAKE_CASE__       ) == len(SCREAMING_SNAKE_CASE__       )
						snake_case_   =	0
						for hypo, pred in zip(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
												em += exact_match_score(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )
						if len(SCREAMING_SNAKE_CASE__       ) > 0:
												em /= len(SCREAMING_SNAKE_CASE__       )
						return {"em": em}


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__       ):
						return model_prefix.startswith('''rag'''       )


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						snake_case_   =	{p: p for p in extra_params}
						# T5 models don't have `dropout` param, they have `dropout_rate` instead
						snake_case_   =	'''dropout_rate'''
						for p in extra_params:
												if getattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
																		if not hasattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ) and not hasattr(SCREAMING_SNAKE_CASE__  ,		equivalent_param[p]       ):
																								logger.info('''config doesn\'t have a `{}` attribute'''.format(SCREAMING_SNAKE_CASE__       )       )
																								delattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )
																								continue
																		snake_case_   =	p if hasattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ) else equivalent_param[p]
																		setattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		getattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )       )
																		delattr(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )
						return hparams, config


import math


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						if 0 not in (x, y):
												# We use the relation x^y = y*log10(x), where 10 is the base.
												return y * math.logaa(SCREAMING_SNAKE_CASE__       )
						else:
												if x == 0:  # 0 raised to any number is 0
																		return 0
												elif y == 0:
																		return 1  # any number raised to 0 is 1
						raise AssertionError('''This should never happen'''       )


if __name__ == "__main__":  # Main function
					# Read two numbers from input and typecast them to int using map function.
					# Here x is the base and y is the power.
					lowerCAmelCase_       	=	'''Enter the base and the power separated by a comma: '''
					lowerCAmelCase_	,      lowerCAmelCase_       	=	map(int, input(prompt).split(''','''))
					lowerCAmelCase_	,      lowerCAmelCase_       	=	map(int, input(prompt).split(''','''))

					# We find the log of each number, using the function res(), which takes two
					# arguments.
					lowerCAmelCase_       	=	res(xa, ya)
					lowerCAmelCase_       	=	res(xa, ya)

					# We check for the largest number
					if resa > resa:
										print('''Largest number is''', xa, '''^''', ya)
					elif resa > resa:
										print('''Largest number is''', xa, '''^''', ya)
					else:
										print('''Both are equal''')