


from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
a					:				int       =      9.8_06_65






def  _UpperCAmelCase						( __lowerCamelCase			,  __lowerCamelCase							)		->Optional[int]:


 '''simple docstring'''

 # Ensure valid instance
 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  _UpperCAmelCase						( __lowerCamelCase			,  __lowerCamelCase							)		->Optional[int]:


 '''simple docstring'''
 check_args(__lowerCamelCase			,  __lowerCamelCase							)
 snake_case :			Union[str, Any]							=   angle_to_radians(2 * angle							)
 return round(init_velocity**2 * sin(__lowerCamelCase							) / g			,  2							)






def  _UpperCAmelCase						( __lowerCamelCase			,  __lowerCamelCase							)		->int:


 '''simple docstring'''
 check_args(__lowerCamelCase			,  __lowerCamelCase							)
 snake_case :			int							=   angle_to_radians(__lowerCamelCase							)
 return round(init_velocity**2 * sin(__lowerCamelCase							) ** 2 / (2 * g)			,  2							)






def  _UpperCAmelCase						( __lowerCamelCase			,  __lowerCamelCase							)		->str:


 '''simple docstring'''
 check_args(__lowerCamelCase			,  __lowerCamelCase							)
 snake_case :			List[str]							=   angle_to_radians(__lowerCamelCase							)
 return round(2 * init_velocity * sin(__lowerCamelCase							) / g			,  2							)






def  _UpperCAmelCase						( )		->Any:


 '''simple docstring'''
 snake_case	,       snake_case :			int							=   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					:				str       =      float(input('Initial Velocity: ').strip())

  # Get input from user
  a					:				Tuple       =      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]''')












import argparse

import torch

from transformers import NystromformerConfig, NystromformerForMaskedLM
def        lowerCamelCase_     (     SCREAMING_SNAKE_CASE ):
			'''simple docstring'''
			if "model" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""model."""       ,						"""""" )
			if "norm1" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""norm1"""       ,						"""attention.output.LayerNorm""" )
			if "norm2" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""norm2"""       ,						"""output.LayerNorm""" )
			if "norm" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""norm"""       ,						"""LayerNorm""" )
			if "transformer" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.split(""".""" )[0].split("""_""" )[-1]
						SCREAMING_SNAKE_CASE     =       orig_key.replace(f"""transformer_{layer_num}"""       ,						f"""encoder.layer.{layer_num}""" )
			if "mha.attn" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""mha.attn"""       ,						"""attention.self""" )
			if "mha" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""mha"""       ,						"""attention""" )
			if "W_q" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""W_q"""       ,						"""self.query""" )
			if "W_k" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""W_k"""       ,						"""self.key""" )
			if "W_v" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""W_v"""       ,						"""self.value""" )
			if "ff1" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""ff1"""       ,						"""intermediate.dense""" )
			if "ff2" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""ff2"""       ,						"""output.dense""" )
			if "ff" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""ff"""       ,						"""output.dense""" )
			if "mlm_class" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""mlm.mlm_class"""       ,						"""cls.predictions.decoder""" )
			if "mlm" in orig_key:
						SCREAMING_SNAKE_CASE     =       orig_key.replace("""mlm"""       ,						"""cls.predictions.transform""" )
			if "cls" not in orig_key:
						SCREAMING_SNAKE_CASE     =       """nystromformer.""" + orig_key

			return orig_key
def        lowerCamelCase_     (     SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE ):
			'''simple docstring'''
			for key in orig_state_dict.copy().keys():
						SCREAMING_SNAKE_CASE     =       orig_state_dict.pop(SCREAMING_SNAKE_CASE )

						if ("pooler" in key) or ("sen_class" in key) or ("conv.bias" in key):
									continue
						else:
									SCREAMING_SNAKE_CASE     =       val

			SCREAMING_SNAKE_CASE     =       orig_state_dict["""cls.predictions.decoder.bias"""]
			SCREAMING_SNAKE_CASE     =       (
			    torch.arange(config.max_position_embeddings ).expand((1, -1) ) + 2
			)

			return orig_state_dict
def        lowerCamelCase_     (     SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE ):
			'''simple docstring'''
			SCREAMING_SNAKE_CASE     =       torch.load(SCREAMING_SNAKE_CASE       ,						map_location="""cpu""" )["""model_state_dict"""]
			SCREAMING_SNAKE_CASE     =       NystromformerConfig.from_json_file(SCREAMING_SNAKE_CASE )
			SCREAMING_SNAKE_CASE     =       NystromformerForMaskedLM(SCREAMING_SNAKE_CASE )

			SCREAMING_SNAKE_CASE     =       convert_checkpoint_helper(SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE )

			model.load_state_dict(SCREAMING_SNAKE_CASE )
			model.eval()
			model.save_pretrained(SCREAMING_SNAKE_CASE )

			print(f"""Checkpoint successfuly converted. Model saved at {pytorch_dump_path}""" )


if __name__ == "__main__":
		__A    :				List[str]    						=	argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    """--pytorch_model_path""", default=None, type=str, required=True, help="""Path to Nystromformer pytorch checkpoint."""
		)
		parser.add_argument(
		    """--config_file""",
		    default=None,
		    type=str,
		    required=True,
		    help="""The json file for Nystromformer model config.""",
		)
		parser.add_argument(
		    """--pytorch_dump_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
		)
		__A    :				Union[str, Any]    						=	parser.parse_args()
		convert_nystromformer_checkpoint(args.pytorch_model_path, args.config_file, args.pytorch_dump_path)






