code: 
  
  
  
  import json
  import os
  import re
  import warnings
  from pathlib import Path
  from shutil import copyfile
  from typing import Any, Dict, List, Optional, Tuple, Union
  
  import sentencepiece
  
  from ...tokenization_utils import PreTrainedTokenizer
  from ...utils import logging
  
  
  __A       					=		logging.get_logger(__name__)
  
  __A       					=		{
      '''source_spm''': '''source.spm''',
      '''target_spm''': '''target.spm''',
      '''vocab''': '''vocab.json''',
      '''target_vocab_file''': '''target_vocab.json''',
      '''tokenizer_config_file''': '''tokenizer_config.json''',
  }
  
  __A       					=		{
      '''source_spm''': {
          '''Helsinki-NLP/opus-mt-en-de''': '''https://huggingface.co/Helsinki-NLP/opus-mt-en-de/resolve/main/source.spm'''
      },
      '''target_spm''': {
          '''Helsinki-NLP/opus-mt-en-de''': '''https://huggingface.co/Helsinki-NLP/opus-mt-en-de/resolve/main/target.spm'''
      },
      '''vocab''': {
          '''Helsinki-NLP/opus-mt-en-de''': '''https://huggingface.co/Helsinki-NLP/opus-mt-en-de/resolve/main/vocab.json'''
      },
      '''tokenizer_config_file''': {
          '''Helsinki-NLP/opus-mt-en-de''': (
              '''https://huggingface.co/Helsinki-NLP/opus-mt-en-de/resolve/main/tokenizer_config.json'''
          )
      },
  }
  
  __A       					=		{'''Helsinki-NLP/opus-mt-en-de''': 512}
  __A       					=		{}
  
  
  
  
  
  
  class 	lowercase		(				snake_case__):
  
  
  
  
  
  
  	"""simple docstring"""
  
  
  	a__   :      List[str]	     =							VOCAB_FILES_NAMES
  	a__   :      Optional[int]	     =							PRETRAINED_VOCAB_FILES_MAP
  	a__   :      Dict	     =							PRETRAINED_INIT_CONFIGURATION
  	a__   :      Optional[Any]	     =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  	a__   :      List[str]	     =							["input_ids", "attention_mask"]
  	a__   :      Dict	     =							re.compile(">>.+<<")  # type: re.Pattern
  
  
  
  
  	def __init__(			self			:		Optional[Any]		,						__UpperCAmelCase			:		str		,						__UpperCAmelCase			:		Dict		,						__UpperCAmelCase			:		Dict		,						__UpperCAmelCase			:		Tuple=None		,						__UpperCAmelCase			:		str=None		,						__UpperCAmelCase			:		Optional[Any]=None		,						__UpperCAmelCase			:		List[Any]="<unk>"		,						__UpperCAmelCase			:		Any="</s>"		,						__UpperCAmelCase			:		Optional[Any]="<pad>"		,						__UpperCAmelCase			:		List[Any]=512		,						__UpperCAmelCase			:		Optional[Dict[str, Any]] = None		,						__UpperCAmelCase			:		int=False		,						**__UpperCAmelCase			:		int		,						)    ->				None:
  							UpperCAmelCase_=     {} if sp_model_kwargs is None else sp_model_kwargs
  
  							super().__init__(
  							    # bos_token=bos_token,  unused. Start decoding with config.decoder_start_token_id
  							    source_lang=__UpperCAmelCase		,						target_lang=__UpperCAmelCase		,						unk_token=__UpperCAmelCase		,						eos_token=__UpperCAmelCase		,						pad_token=__UpperCAmelCase		,						model_max_length=__UpperCAmelCase		,						sp_model_kwargs=self.sp_model_kwargs		,						target_vocab_file=__UpperCAmelCase		,						separate_vocabs=__UpperCAmelCase		,						**__UpperCAmelCase		,						)
  							assert Path(__UpperCAmelCase  ).exists(), F"""cannot find spm source {source_spm}"""
  
  							UpperCAmelCase_=     separate_vocabs
  							UpperCAmelCase_=     load_json(__UpperCAmelCase  )
  							if self.unk_token not in self.encoder:
  													raise KeyError("""<unk> token must be in vocab"""  )
  							assert self.pad_token in self.encoder
  
  							if separate_vocabs:
  													UpperCAmelCase_=     load_json(__UpperCAmelCase  )
  													UpperCAmelCase_=     {v: k for k, v in self.target_encoder.items()}
  													UpperCAmelCase_=     []
  							else:
  													UpperCAmelCase_=     {v: k for k, v in self.encoder.items()}
  													UpperCAmelCase_=     [k for k in self.encoder if k.startswith(""">>"""  ) and k.endswith("""<<"""  )]
  
  							UpperCAmelCase_=     source_lang
  							UpperCAmelCase_=     target_lang
  							UpperCAmelCase_=     [source_spm, target_spm]
  
  							# load SentencePiece model for pre-processing
  							UpperCAmelCase_=     load_spm(__UpperCAmelCase		,						self.sp_model_kwargs  )
  							UpperCAmelCase_=     load_spm(__UpperCAmelCase		,						self.sp_model_kwargs  )
  							UpperCAmelCase_=     self.spm_source
  							UpperCAmelCase_=     self.encoder
  
  							# Multilingual target side: default to using first supported language code.
  
  							self._setup_normalizer()
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		str  )    ->				int:
  							try:
  													from sacremoses import MosesPunctNormalizer
  
  													UpperCAmelCase_=     MosesPunctNormalizer(self.source_lang  ).normalize
  							except (ImportError, FileNotFoundError):
  													warnings.warn("""Recommended: pip install sacremoses."""  )
  													UpperCAmelCase_=     lambda __UpperCAmelCase  : x
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]		,						__UpperCAmelCase			:		str  )    ->				str:
  							return self.punc_normalizer(__UpperCAmelCase  ) if x else ""
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Union[str, Any]		,						__UpperCAmelCase			:		List[Any]  )    ->				Any:
  							return self.current_encoder.get(__UpperCAmelCase		,						self.current_encoder[self.unk_token]  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		str		,						__UpperCAmelCase			:		str  )    ->				int:
  							UpperCAmelCase_=     self.language_code_re.match(__UpperCAmelCase  )
  							UpperCAmelCase_=     [match.group(0  )] if match else []
  							return code, self.language_code_re.sub(""""""		,						__UpperCAmelCase  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[str]		,						__UpperCAmelCase			:		str  )    ->				List[str]:
  							UpperCAmelCase_,     UpperCAmelCase_=     self.remove_language_code(__UpperCAmelCase  )
  							UpperCAmelCase_=     self.current_spm.encode(__UpperCAmelCase		,						out_type=__UpperCAmelCase  )
  							return code + pieces
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]		,						__UpperCAmelCase			:		int  )    ->				str:
  							return self.decoder.get(__UpperCAmelCase		,						self.unk_token  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]		,						__UpperCAmelCase			:		Union[str, Any]		,						**__UpperCAmelCase			:		Optional[int]  )    ->				str:
  							return super().batch_decode(__UpperCAmelCase		,						**__UpperCAmelCase  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Optional[int]		,						__UpperCAmelCase			:		List[Any]		,						**__UpperCAmelCase			:		Tuple  )    ->				List[Any]:
  							return super().decode(__UpperCAmelCase		,						**__UpperCAmelCase  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Optional[int]		,						__UpperCAmelCase			:		List[str]  )    ->				str:
  							UpperCAmelCase_=     self.spm_source if self._decode_use_source_tokenizer else self.spm_target
  							UpperCAmelCase_=     []
  							UpperCAmelCase_=     """"""
  							for token in tokens:
  													# make sure that special tokens are not decoded using sentencepiece model
  													if token in self.all_special_tokens:
  																			out_string += sp_model.decode_pieces(__UpperCAmelCase  ) + token + " "
  																			UpperCAmelCase_=     []
  													else:
  																			current_sub_tokens.append(__UpperCAmelCase  )
  							out_string += sp_model.decode_pieces(__UpperCAmelCase  )
  							return out_string.strip()
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Any		,						__UpperCAmelCase			:		Union[str, Any]		,						__UpperCAmelCase			:		Optional[int]=None  )    ->				List[int]:
  							if token_ids_a is None:
  													return token_ids_a + [self.eos_token_id]
  							# We don't expect to process pairs, but leave the pair logic for API consistency
  							return token_ids_a + token_ids_a + [self.eos_token_id]
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]  )    ->				List[str]:
  							UpperCAmelCase_=     self.spm_source
  							UpperCAmelCase_=     self.encoder
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Dict  )    ->				Union[str, Any]:
  							UpperCAmelCase_=     self.spm_target
  							if self.separate_vocabs:
  													UpperCAmelCase_=     self.target_encoder
  
  
  
  
  	@property
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[str]  )    ->				int:
  							return len(self.encoder  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		int		,						__UpperCAmelCase			:		str		,						__UpperCAmelCase			:		Optional[str] = None  )    ->				Tuple[str]:
  							if not os.path.isdir(__UpperCAmelCase  ):
  													logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""  )
  													return
  							UpperCAmelCase_=     []
  
  							if self.separate_vocabs:
  													UpperCAmelCase_=     os.path.join(
  													    __UpperCAmelCase		,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab"""]		,						)
  													UpperCAmelCase_=     os.path.join(
  													    __UpperCAmelCase		,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""target_vocab_file"""]		,						)
  													save_json(self.encoder		,						__UpperCAmelCase  )
  													save_json(self.target_encoder		,						__UpperCAmelCase  )
  													saved_files.append(__UpperCAmelCase  )
  													saved_files.append(__UpperCAmelCase  )
  							else:
  													UpperCAmelCase_=     os.path.join(
  													    __UpperCAmelCase		,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab"""]  )
  													save_json(self.encoder		,						__UpperCAmelCase  )
  													saved_files.append(__UpperCAmelCase  )
  
  							for spm_save_filename, spm_orig_path, spm_model in zip(
  							    [VOCAB_FILES_NAMES["""source_spm"""], VOCAB_FILES_NAMES["""target_spm"""]]		,						self.spm_files		,						[self.spm_source, self.spm_target]		,						):
  													UpperCAmelCase_=     os.path.join(
  													    __UpperCAmelCase		,						(filename_prefix + """-""" if filename_prefix else """""") + spm_save_filename  )
  													if os.path.abspath(__UpperCAmelCase  ) != os.path.abspath(__UpperCAmelCase  ) and os.path.isfile(__UpperCAmelCase  ):
  																			copyfile(__UpperCAmelCase		,						__UpperCAmelCase  )
  																			saved_files.append(__UpperCAmelCase  )
  													elif not os.path.isfile(__UpperCAmelCase  ):
  																			with open(__UpperCAmelCase		,						"""wb"""  ) as fi:
  																									UpperCAmelCase_=     spm_model.serialized_model_proto()
  																									fi.write(__UpperCAmelCase  )
  																			saved_files.append(__UpperCAmelCase  )
  
  							return tuple(__UpperCAmelCase  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Union[str, Any]  )    ->				Dict:
  							return self.get_src_vocab()
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Dict  )    ->				Any:
  							return dict(self.encoder		,						**self.added_tokens_encoder  )
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Union[str, Any]  )    ->				int:
  							return dict(self.target_encoder		,						**self.added_tokens_decoder  )
  
  
  
  
  	def __getstate__(			self			:		List[Any]  )    ->				Dict:
  							UpperCAmelCase_=     self.__dict__.copy()
  							state.update(
  							    {k: None for k in ["""spm_source""", """spm_target""", """current_spm""", """punc_normalizer""", """target_vocab_file"""]}  )
  							return state
  
  
  
  
  	def __setstate__(			self			:		int		,						__UpperCAmelCase			:		Dict  )    ->				None:
  							UpperCAmelCase_=     d
  
  							# for backward compatibility
  							if not hasattr(self		,						"""sp_model_kwargs"""  ):
  													UpperCAmelCase_=     {}
  
  							UpperCAmelCase_,     UpperCAmelCase_=     (load_spm(__UpperCAmelCase		,						self.sp_model_kwargs  ) for f in self.spm_files)
  							UpperCAmelCase_=     self.spm_source
  							self._setup_normalizer()
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		Any		,						*__UpperCAmelCase			:		Union[str, Any]		,						**__UpperCAmelCase			:		Dict  )    ->				Optional[Any]:
  							return 1
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]		,						__UpperCAmelCase			:		str  )    ->				Tuple:
  							UpperCAmelCase_=     set(self.all_special_ids  )  # call it once instead of inside list comp
  							all_special_ids.remove(self.unk_token_id  )  # <unk> is only sometimes special
  							return [1 if x in all_special_ids else 0 for x in seq]
  
  
  
  
  	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]		,						__UpperCAmelCase			:		List		,						__UpperCAmelCase			:		Optional[List] = None		,						__UpperCAmelCase			:		bool = False  )    ->				List[int]:
  							if already_has_special_tokens:
  													return self._special_token_mask(__UpperCAmelCase  )
  							elif token_ids_a is None:
  													return self._special_token_mask(__UpperCAmelCase  ) + [1]
  							else:
  													return self._special_token_mask(token_ids_a + token_ids_a  ) + [1]
  
  
  
  def  __a  (					lowerCAmelCase_     :      str    ,lowerCAmelCase_     :      Dict[str, Any]       )   ->				sentencepiece.SentencePieceProcessor:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCAmelCase_=     sentencepiece.SentencePieceProcessor(**lowerCAmelCase_       )
  						spm.Load(lowerCAmelCase_       )
  						return spm
  
  
  
  def  __a  (					lowerCAmelCase_     :      Optional[Any]    ,lowerCAmelCase_     :      str       )   ->				None:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						with open(lowerCAmelCase_    ,"""w"""       ) as f:
  												json.dump(lowerCAmelCase_    ,lowerCAmelCase_    ,indent=2       )
  
  
  
  def  __a  (					lowerCAmelCase_     :      str       )   ->				Union[Dict, List]:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						with open(lowerCAmelCase_    ,"""r"""       ) as f:
  												return json.load(lowerCAmelCase_       )
  
  
  
  
  
style_context: 
  
  
  
  from math import radians as angle_to_radians
  from math import sin
  
  # Acceleration Constant on Earth (unit m/s^2)
  __A       					=		9.8_0_6_6_5
  
  
  
  def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				None:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						if not isinstance(lowerCAmelCase_    ,(int, float)       ):
  												raise TypeError("""Invalid velocity. Should be a positive number."""       )
  
  						if not isinstance(lowerCAmelCase_    ,(int, float)       ):
  												raise TypeError("""Invalid angle. Range is 1-90 degrees."""       )
  
  						# Ensure valid angle
  						if angle > 90 or angle < 1:
  												raise ValueError("""Invalid angle. Range is 1-90 degrees."""       )
  
  						# Ensure valid velocity
  						if init_velocity < 0:
  												raise ValueError("""Invalid velocity. Should be a positive number."""       )
  
  
  
  def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				float:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						check_args(lowerCAmelCase_    ,lowerCAmelCase_       )
  						UpperCAmelCase_=     angle_to_radians(2 * angle       )
  						return round(init_velocity**2 * sin(lowerCAmelCase_       ) / g    ,2       )
  
  
  
  def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				float:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						check_args(lowerCAmelCase_    ,lowerCAmelCase_       )
  						UpperCAmelCase_=     angle_to_radians(lowerCAmelCase_       )
  						return round(init_velocity**2 * sin(lowerCAmelCase_       ) ** 2 / (2 * g)    ,2       )
  
  
  
  def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				float:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						check_args(lowerCAmelCase_    ,lowerCAmelCase_       )
  						UpperCAmelCase_=     angle_to_radians(lowerCAmelCase_       )
  						return round(2 * init_velocity * sin(lowerCAmelCase_       ) / g    ,2       )
  
  
  
  def  __a  (					)   ->				None:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCAmelCase_,     UpperCAmelCase_=     25, 20
  						assert horizontal_distance(lowerCAmelCase_    ,lowerCAmelCase_       ) == 40.97
  						assert max_height(lowerCAmelCase_    ,lowerCAmelCase_       ) == 3.73
  						assert total_time(lowerCAmelCase_    ,lowerCAmelCase_       ) == 1.74
  
  
  if __name__ == "__main__":
  	from doctest import testmod
  
  	testmod()
  
  	# Get input from user
  	__A       					=		float(input('''Initial Velocity: ''').strip())
  
  	# Get input from user
  	__A       					=		float(input('''angle: ''').strip())
  
  	# Print results
  	print()
  	print('''Results: ''')
  	print(f'Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]')
  	print(f'Maximum Height: {max_height(init_vel, angle)!s} [m]')
  	print(f'Total Time: {total_time(init_vel, angle)!s} [s]')
  
  
  
  
  