


import logging
import os

from .state import PartialState




class 				UpperCamelCase_			(				logging.LoggerAdapter):

	"""simple docstring"""





	@staticmethod
	def 						UpperCAmelCase_   (				UpperCAmelCase__    :       List[str]     ) ->			Optional[int]:
						__SCREAMING_SNAKE_CASE		     =       PartialState()
						return not main_process_only or (main_process_only and state.is_main_process)




	def 						UpperCAmelCase_   (				self    :       Optional[int]    ,    UpperCAmelCase__    :       Any    ,    UpperCAmelCase__    :       Dict    ,    *UpperCAmelCase__    :       int    ,    **UpperCAmelCase__    :       Dict     ) ->			Optional[int]:
						if PartialState._shared_state == {}:
											raise RuntimeError(
											    "You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility."     )
						__SCREAMING_SNAKE_CASE		     =       kwargs.pop("main_process_only"    ,    A_     )
						__SCREAMING_SNAKE_CASE		     =       kwargs.pop("in_order"    ,    A_     )

						if self.isEnabledFor(A_     ):
											if self._should_log(A_     ):
																__SCREAMING_SNAKE_CASE     ,						__SCREAMING_SNAKE_CASE		     =       self.process(A_    ,    A_     )
																self.logger.log(A_    ,    A_    ,    *A_    ,    **A_     )

											elif in_order:
																__SCREAMING_SNAKE_CASE		     =       PartialState()
																for i in range(state.num_processes     ):
																					if i == state.process_index:
																										__SCREAMING_SNAKE_CASE     ,						__SCREAMING_SNAKE_CASE		     =       self.process(A_    ,    A_     )
																										self.logger.log(A_    ,    A_    ,    *A_    ,    **A_     )
																					state.wait_for_everyone()




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_ = None     ):




					'''simple docstring'''


					if log_level is None:
										__SCREAMING_SNAKE_CASE		     =       os.environ.get("ACCELERATE_LOG_LEVEL"						,		snake_case__     )
					__SCREAMING_SNAKE_CASE		     =       logging.getLogger(snake_case__     )
					if log_level is not None:
										logger.setLevel(log_level.upper()     )
										logger.root.setLevel(log_level.upper()     )
					return MultiProcessAdapter(snake_case__						,		{}     )




"""simple docstring"""







from math import asin, atan, cos, radians, sin, sqrt, tan

a__       :							List[str]        =  6_37_81_37.0
a__       :							Tuple        =  6_35_67_52.31_42_45
a__       :							str        =  6_3_7_8_1_3_7




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       (AXIS_A - AXIS_B) / AXIS_A
					__SCREAMING_SNAKE_CASE		     =       atan((1 - flattening) * tan(radians(lowerCAmelCase_     )     )     )
					__SCREAMING_SNAKE_CASE		     =       atan((1 - flattening) * tan(radians(lowerCAmelCase_     )     )     )
					__SCREAMING_SNAKE_CASE		     =       radians(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       radians(lowerCAmelCase_     )
					# Equation
					__SCREAMING_SNAKE_CASE		     =       sin((phi_a - phi_a) / 2     )
					__SCREAMING_SNAKE_CASE		     =       sin((lambda_a - lambda_a) / 2     )
					# Square both values
					sin_sq_phi *= sin_sq_phi
					sin_sq_lambda *= sin_sq_lambda
					__SCREAMING_SNAKE_CASE		     =       sqrt(sin_sq_phi + (cos(lowerCAmelCase_     ) * cos(lowerCAmelCase_     ) * sin_sq_lambda)     )
					return 2 * RADIUS * asin(lowerCAmelCase_     )


if __name__ == "__main__":
		import doctest

		doctest.testmod()
