



'''simple docstring'''







import os
import warnings
from pathlib import Path
from typing import Optional, Union

from .dynamic_module_utils import custom_object_save
from .tokenization_utils_base import PreTrainedTokenizerBase
from .utils import PushToHubMixin, copy_func, direct_transformers_import, logging


lowercase__     :  Tuple    					=			logging.get_logger(__name__)

# Dynamically import the Transformers module to grab the attribute classes of the processor form their names.
lowercase__     :  List[str]    					=			direct_transformers_import(Path(__file__).parent)


lowercase__     :  Optional[Any]    					=			{
    'AutoTokenizer': 'PreTrainedTokenizerBase',
    'AutoFeatureExtractor': 'FeatureExtractionMixin',
    'AutoImageProcessor': 'ImageProcessingMixin',
}

class       lowerCamelCase_							(	lowerCAmelCase_  ):






   '''simple docstring'''

   A :     List[str]				=	["feature_extractor", "tokenizer"]
   # Names need to be attr_class for attr in attributes
   A :     str				=	None
   A :     Optional[Any]				=	None
   A :     Union[str, Any]				=	None


   def __init__(  self     ,						*__UpperCamelCase     ,						**__UpperCamelCase ):
       # Sanitize args and kwargs
       for key in kwargs:
           if key not in self.attributes:
               raise TypeError(f'Unexpected keyword argument {key}.' )
       for arg, attribute_name in zip(__UpperCamelCase     ,						self.attributes ):
           if attribute_name in kwargs:
               raise TypeError(f'Got multiple values for argument {attribute_name}.' )
           else:
               UpperCamelCase__      =			arg

       if len(__UpperCamelCase ) != len(self.attributes ):
           raise ValueError(
               f'This processor requires {len(self.attributes )} arguments: {", ".join(self.attributes )}. Got '
               f'{len(__UpperCamelCase )} arguments instead.' )

       # Check each arg is of the proper class (this will also catch a user initializing in the wrong order)
       for attribute_name, arg in kwargs.items():
           UpperCamelCase__      =			getattr(self     ,						f'{attribute_name}_class' )
           # Nothing is ever going to be an instance of "AutoXxx", in that case we check the base class.
           UpperCamelCase__      =			AUTO_TO_BASE_CLASS_MAPPING.get(__UpperCamelCase     ,						__UpperCamelCase )
           if isinstance(__UpperCamelCase     ,						__UpperCamelCase ):
               UpperCamelCase__      =			tuple(getattr(__UpperCamelCase     ,						__UpperCamelCase ) for n in class_name if n is not None )
           else:
               UpperCamelCase__      =			getattr(__UpperCamelCase     ,						__UpperCamelCase )

           if not isinstance(__UpperCamelCase     ,						__UpperCamelCase ):
               raise ValueError(
                   f'Received a {type(__UpperCamelCase ).__name__} for argument {attribute_name}, but a {class_name} was expected.' )

           setattr(self     ,						__UpperCamelCase     ,						__UpperCamelCase )


   def __repr__(  self ):
       UpperCamelCase__      =			[f'- {name}: {repr(getattr(self     ,						__UpperCamelCase ) )}' for name in self.attributes]
       UpperCamelCase__      =			"\n".join(__UpperCamelCase )
       return f'{self.__class__.__name__}:\n{attributes_repr}'


   def 	_UpperCamelCase       (  self     ,						__UpperCamelCase     ,						__UpperCamelCase = False     ,						**__UpperCamelCase ):
       os.makedirs(__UpperCamelCase     ,						exist_ok=__UpperCamelCase )

       if push_to_hub:
           UpperCamelCase__      =			kwargs.pop("commit_message"     ,						__UpperCamelCase )
           UpperCamelCase__      =			kwargs.pop("repo_id"     ,						save_directory.split(os.path.sep )[-1] )
           UpperCamelCase__      =			self._create_repo(__UpperCamelCase     ,						**__UpperCamelCase )
           UpperCamelCase__      =			self._get_files_timestamps(__UpperCamelCase )
       # If we have a custom config, we copy the file defining it in the folder and set the attributes so it can be
       # loaded from the Hub.
       if self._auto_class is not None:
           UpperCamelCase__      =			[getattr(self     ,						__UpperCamelCase ) for attribute_name in self.attributes]
           UpperCamelCase__      =			[(a.init_kwargs if isinstance(__UpperCamelCase     ,						__UpperCamelCase ) else a) for a in attrs]
           custom_object_save(self     ,						__UpperCamelCase     ,						config=__UpperCamelCase )

       for attribute_name in self.attributes:
           UpperCamelCase__      =			getattr(self     ,						__UpperCamelCase )
           # Include the processor class in the attribute config so this processor can then be reloaded with the
           # `AutoProcessor` API.
           if hasattr(__UpperCamelCase     ,						"_set_processor_class" ):
               attribute._set_processor_class(self.__class__.__name__ )
           attribute.save_pretrained(__UpperCamelCase )

       if self._auto_class is not None:
           # We added an attribute to the init_kwargs of the tokenizers, which needs to be cleaned up.
           for attribute_name in self.attributes:
               UpperCamelCase__      =			getattr(self     ,						__UpperCamelCase )
               if isinstance(__UpperCamelCase     ,						__UpperCamelCase ):
                   del attribute.init_kwargs["auto_map"]

       if push_to_hub:
           self._upload_modified_files(
               __UpperCamelCase     ,						__UpperCamelCase     ,						__UpperCamelCase     ,						commit_message=__UpperCamelCase     ,						token=kwargs.get("use_auth_token" )     ,						)


   @classmethod
   def 	_UpperCamelCase       (  cls     ,						__UpperCamelCase     ,						__UpperCamelCase = None     ,						__UpperCamelCase = False     ,						__UpperCamelCase = False     ,						__UpperCamelCase = None     ,						__UpperCamelCase = "main"     ,						**__UpperCamelCase     ,						):
       UpperCamelCase__      =			cache_dir
       UpperCamelCase__      =			force_download
       UpperCamelCase__      =			local_files_only
       UpperCamelCase__      =			revision

       UpperCamelCase__      =			kwargs.pop("use_auth_token"     ,						__UpperCamelCase )
       if use_auth_token is not None:
           warnings.warn(
               "The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers."     ,						__UpperCamelCase )
           if token is not None:
               raise ValueError(
                   "`token` and `use_auth_token` are both specified. Please set only the argument `token`." )
           UpperCamelCase__      =			use_auth_token

       if token is not None:
           # change to `token` in a follow-up PR
           UpperCamelCase__      =			token

       UpperCamelCase__      =			cls._get_arguments_from_pretrained(__UpperCamelCase     ,						**__UpperCamelCase )
       return cls(*__UpperCamelCase )


   @classmethod
   def 	_UpperCamelCase       (  cls     ,						__UpperCamelCase="AutoProcessor" ):
       if not isinstance(__UpperCamelCase     ,						__UpperCamelCase ):
           UpperCamelCase__      =			auto_class.__name__

       import transformers.models.auto as auto_module

       if not hasattr(__UpperCamelCase     ,						__UpperCamelCase ):
           raise ValueError(f'{auto_class} is not a valid auto class.' )

       UpperCamelCase__      =			auto_class


   @classmethod
   def 	_UpperCamelCase       (  cls     ,						__UpperCamelCase     ,						**__UpperCamelCase ):
       UpperCamelCase__      =			[]
       for attribute_name in cls.attributes:
           UpperCamelCase__      =			getattr(cls     ,						f'{attribute_name}_class' )
           if isinstance(__UpperCamelCase     ,						__UpperCamelCase ):
               UpperCamelCase__      =			tuple(getattr(__UpperCamelCase     ,						__UpperCamelCase ) if n is not None else None for n in class_name )
               UpperCamelCase__      =			kwargs.get("use_fast"     ,						__UpperCamelCase )
               if use_fast and classes[1] is not None:
                   UpperCamelCase__      =			classes[1]
               else:
                   UpperCamelCase__      =			classes[0]
           else:
               UpperCamelCase__      =			getattr(__UpperCamelCase     ,						__UpperCamelCase )

           args.append(attribute_class.from_pretrained(__UpperCamelCase     ,						**__UpperCamelCase ) )
       return args







   @property
   def 	_UpperCamelCase       (  self ):
       UpperCamelCase__      =			getattr(self     ,						self.attributes[0] )
       return getattr(__UpperCamelCase     ,						"model_input_names"     ,						__UpperCamelCase )

lowercase__     :  Tuple    					=			copy_func(ProcessorMixin.push_to_hub)
if ProcessorMixin.push_to_hub.__doc__ is not None:
      lowercase__     :  Dict    					=			ProcessorMixin.push_to_hub.__doc__.format(
          object='processor', object_class='AutoProcessor', object_files='processor files'
      )









'''simple docstring'''







from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
lowercase__     :  str    					=			9.8_0_6_6_5





def 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):

    # 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 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):
    check_args(lowerCAmelCase_					,  lowerCAmelCase_	)
    UpperCamelCase__      =			angle_to_radians(2 * angle	)
    return round(init_velocity**2 * sin(lowerCAmelCase_	) / g					,  2	)





def 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):
    check_args(lowerCAmelCase_					,  lowerCAmelCase_	)
    UpperCamelCase__      =			angle_to_radians(lowerCAmelCase_	)
    return round(init_velocity**2 * sin(lowerCAmelCase_	) ** 2 / (2 * g)					,  2	)





def 						snake_case__ (lowerCAmelCase_					,  lowerCAmelCase_	):
    check_args(lowerCAmelCase_					,  lowerCAmelCase_	)
    UpperCamelCase__      =			angle_to_radians(lowerCAmelCase_	)
    return round(2 * init_velocity * sin(lowerCAmelCase_	) / g					,  2	)





def 						snake_case__ ():
    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
      lowercase__     :  Union[str, Any]    					=			float(input('Initial Velocity: ').strip())

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




