


'''simple docstring'''
import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
		pass

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__snake_case							   =  logging.get_logger(__name__)

__snake_case							   =  {
    '''kakaobrain/align-base''': '''https://huggingface.co/kakaobrain/align-base/resolve/main/config.json''',
}
class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'align_text_model'




		def __init__(	self					,     UpperCamelCase_=30522					,     UpperCamelCase_=768					,     UpperCamelCase_=12					,     UpperCamelCase_=12					,     UpperCamelCase_=3072					,     UpperCamelCase_="gelu"					,     UpperCamelCase_=0.1					,     UpperCamelCase_=0.1					,     UpperCamelCase_=512					,     UpperCamelCase_=2					,     UpperCamelCase_=0.02					,     UpperCamelCase_=1e-12					,     UpperCamelCase_=0					,     UpperCamelCase_="absolute"					,     UpperCamelCase_=True					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							super().__init__(**UpperCamelCase_							)

							UpperCamelCase__     :Dict							      =				vocab_size
							UpperCamelCase__     :Union[str, Any]							      =				hidden_size
							UpperCamelCase__     :Tuple							      =				num_hidden_layers
							UpperCamelCase__     :Dict							      =				num_attention_heads
							UpperCamelCase__     :List[str]							      =				hidden_act
							UpperCamelCase__     :List[str]							      =				intermediate_size
							UpperCamelCase__     :List[str]							      =				hidden_dropout_prob
							UpperCamelCase__     :Union[str, Any]							      =				attention_probs_dropout_prob
							UpperCamelCase__     :Union[str, Any]							      =				max_position_embeddings
							UpperCamelCase__     :Any							      =				type_vocab_size
							UpperCamelCase__     :Optional[int]							      =				initializer_range
							UpperCamelCase__     :Any							      =				layer_norm_eps
							UpperCamelCase__     :str							      =				position_embedding_type
							UpperCamelCase__     :Tuple							      =				use_cache
							UpperCamelCase__     :int							      =				pad_token_id




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							cls._set_token_in_kwargs(UpperCamelCase_							)

							UpperCamelCase__      ,       UpperCamelCase__     :List[str]							      =				cls.get_config_dict(UpperCamelCase_					,     **UpperCamelCase_							)

							# get the text config dict if we are loading from AlignConfig
							if config_dict.get('''model_type'''							) == "align":
												UpperCamelCase__     :Dict							      =				config_dict['''text_config''']

							if "model_type" in config_dict and hasattr(cls					,     '''model_type'''							) and config_dict["model_type"] != cls.model_type:
												logger.warning(
												    F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
												    F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

							return cls.from_dict(UpperCamelCase_					,     **UpperCamelCase_							)



class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'align_vision_model'




		def __init__(	self					,     UpperCamelCase_ = 3					,     UpperCamelCase_ = 600					,     UpperCamelCase_ = 2.0					,     UpperCamelCase_ = 3.1					,     UpperCamelCase_ = 8					,     UpperCamelCase_ = [3, 3, 5, 3, 5, 5, 3]					,     UpperCamelCase_ = [32, 16, 24, 40, 80, 112, 192]					,     UpperCamelCase_ = [16, 24, 40, 80, 112, 192, 320]					,     UpperCamelCase_ = []					,     UpperCamelCase_ = [1, 2, 2, 2, 1, 2, 1]					,     UpperCamelCase_ = [1, 2, 2, 3, 3, 4, 1]					,     UpperCamelCase_ = [1, 6, 6, 6, 6, 6, 6]					,     UpperCamelCase_ = 0.25					,     UpperCamelCase_ = "swish"					,     UpperCamelCase_ = 2560					,     UpperCamelCase_ = "mean"					,     UpperCamelCase_ = 0.02					,     UpperCamelCase_ = 0.001					,     UpperCamelCase_ = 0.99					,     UpperCamelCase_ = 0.2					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							super().__init__(**UpperCamelCase_							)

							UpperCamelCase__     :List[Any]							      =				num_channels
							UpperCamelCase__     :Any							      =				image_size
							UpperCamelCase__     :Dict							      =				width_coefficient
							UpperCamelCase__     :int							      =				depth_coefficient
							UpperCamelCase__     :Union[str, Any]							      =				depth_divisor
							UpperCamelCase__     :Optional[Any]							      =				kernel_sizes
							UpperCamelCase__     :Any							      =				in_channels
							UpperCamelCase__     :Dict							      =				out_channels
							UpperCamelCase__     :str							      =				depthwise_padding
							UpperCamelCase__     :Tuple							      =				strides
							UpperCamelCase__     :Optional[int]							      =				num_block_repeats
							UpperCamelCase__     :List[str]							      =				expand_ratios
							UpperCamelCase__     :Union[str, Any]							      =				squeeze_expansion_ratio
							UpperCamelCase__     :Union[str, Any]							      =				hidden_act
							UpperCamelCase__     :Optional[int]							      =				hidden_dim
							UpperCamelCase__     :Optional[Any]							      =				pooling_type
							UpperCamelCase__     :Optional[int]							      =				initializer_range
							UpperCamelCase__     :Tuple							      =				batch_norm_eps
							UpperCamelCase__     :Optional[Any]							      =				batch_norm_momentum
							UpperCamelCase__     :Optional[Any]							      =				drop_connect_rate
							UpperCamelCase__     :str							      =				sum(UpperCamelCase_							) * 4




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							cls._set_token_in_kwargs(UpperCamelCase_							)

							UpperCamelCase__      ,       UpperCamelCase__     :Union[str, Any]							      =				cls.get_config_dict(UpperCamelCase_					,     **UpperCamelCase_							)

							# get the vision config dict if we are loading from AlignConfig
							if config_dict.get('''model_type'''							) == "align":
												UpperCamelCase__     :Union[str, Any]							      =				config_dict['''vision_config''']

							if "model_type" in config_dict and hasattr(cls					,     '''model_type'''							) and config_dict["model_type"] != cls.model_type:
												logger.warning(
												    F'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
												    F'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''							)

							return cls.from_dict(UpperCamelCase_					,     **UpperCamelCase_							)



class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'align'
		_a									=       True




		def __init__(	self					,     UpperCamelCase_=None					,     UpperCamelCase_=None					,     UpperCamelCase_=640					,     UpperCamelCase_=1.0					,     UpperCamelCase_=0.02					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							super().__init__(**UpperCamelCase_							)

							if text_config is None:
												UpperCamelCase__     :Dict							      =				{}
												logger.info('''text_config is None. Initializing the AlignTextConfig with default values.'''							)

							if vision_config is None:
												UpperCamelCase__     :str							      =				{}
												logger.info('''vision_config is None. Initializing the AlignVisionConfig with default values.'''							)

							UpperCamelCase__     :str							      =				AlignTextConfig(**UpperCamelCase_							)
							UpperCamelCase__     :Dict							      =				AlignVisionConfig(**UpperCamelCase_							)

							UpperCamelCase__     :Optional[Any]							      =				projection_dim
							UpperCamelCase__     :Optional[int]							      =				temperature_init_value
							UpperCamelCase__     :List[Any]							      =				initializer_range




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							return cls(text_config=text_config.to_dict()					,     vision_config=vision_config.to_dict()					,     **UpperCamelCase_							)




		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							UpperCamelCase__     :Optional[int]							      =				copy.deepcopy(self.__dict__							)
							UpperCamelCase__     :Union[str, Any]							      =				self.text_config.to_dict()
							UpperCamelCase__     :List[str]							      =				self.vision_config.to_dict()
							UpperCamelCase__     :Dict							      =				self.__class__.model_type
							return output



'''simple docstring'''
from __future__ import annotations

from decimal import Decimal
from math import *  # noqa: F403

from sympy import diff


def     a   (    __a				,      __a				,      __a = 10**-10     )						->			float:



					'''simple docstring'''






					UpperCamelCase__     :Tuple							      =				a
					while True:
										UpperCamelCase__     :Dict							      =				Decimal(__a     ) - (
										    Decimal(eval(__a     )     ) / Decimal(eval(str(diff(__a     )     )     )     )  # noqa: S307
										)
										# This number dictates the accuracy of the answer
										if abs(eval(__a     )     ) < precision:  # noqa: S307
															return float(__a     )


# Let's Execute
if __name__ == "__main__":
		# Find root of trigonometric function
		# Find value of pi
		print(F"""The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}""")
		# Find root of polynomial
		print(F"""The root of x**2 - 5*x + 2 = 0 is {newton_raphson('x**2 - 5*x + 2', 0.4)}""")
		# Find Square Root of 5
		print(F"""The root of log(x) - 1 = 0 is {newton_raphson('log(x) - 1', 2)}""")
		# Exponential Roots
		print(F"""The root of exp(x) - 1 = 0 is {newton_raphson('exp(x) - 1', 0)}""")