


import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
		pass

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


lowerCamelCase :    Optional[int]						=		logging.get_logger(__name__)

lowerCamelCase :    Dict						=		{
    '''kakaobrain/align-base''': '''https://huggingface.co/kakaobrain/align-base/resolve/main/config.json''',
}





class  _a							(    _lowercase):
	_a  :  Union[str, Any]				   =							'''align_text_model'''




	def __init__( self						:		Any		, _SCREAMING_SNAKE_CASE						:		Tuple=3_0522		, _SCREAMING_SNAKE_CASE						:		Dict=768		, _SCREAMING_SNAKE_CASE						:		List[str]=12		, _SCREAMING_SNAKE_CASE						:		Optional[int]=12		, _SCREAMING_SNAKE_CASE						:		Union[str, Any]=3072		, _SCREAMING_SNAKE_CASE						:		Optional[Any]="gelu"		, _SCREAMING_SNAKE_CASE						:		Tuple=0.1		, _SCREAMING_SNAKE_CASE						:		Optional[Any]=0.1		, _SCREAMING_SNAKE_CASE						:		List[Any]=512		, _SCREAMING_SNAKE_CASE						:		Optional[int]=2		, _SCREAMING_SNAKE_CASE						:		List[str]=0.02		, _SCREAMING_SNAKE_CASE						:		Union[str, Any]=1E-12		, _SCREAMING_SNAKE_CASE						:		Any=0		, _SCREAMING_SNAKE_CASE						:		List[str]="absolute"		, _SCREAMING_SNAKE_CASE						:		List[Any]=True		, **_SCREAMING_SNAKE_CASE						:		str		, )->	Optional[Any]:
			super().__init__(**_SCREAMING_SNAKE_CASE		)

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




	@classmethod
	def 							UpperCAmelCase__( cls						:		Any		, _SCREAMING_SNAKE_CASE						:		Union[str, os.PathLike]		, **_SCREAMING_SNAKE_CASE						:		Union[str, Any]		)->	"PretrainedConfig":
			cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      Any   					= cls.get_config_dict(_SCREAMING_SNAKE_CASE		, **_SCREAMING_SNAKE_CASE		)

			# get the text config dict if we are loading from AlignConfig
			if config_dict.get('''model_type'''		) == "align":
					lowerCAmelCase__       :      List[Any]   					= 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(_SCREAMING_SNAKE_CASE		, **_SCREAMING_SNAKE_CASE		)





class  _a							(    _lowercase):
	_a  :  Any				   =							'''align_vision_model'''




	def __init__( self						:		Any		, _SCREAMING_SNAKE_CASE						:		int = 3		, _SCREAMING_SNAKE_CASE						:		int = 600		, _SCREAMING_SNAKE_CASE						:		float = 2.0		, _SCREAMING_SNAKE_CASE						:		float = 3.1		, _SCREAMING_SNAKE_CASE						:		int = 8		, _SCREAMING_SNAKE_CASE						:		List[int] = [3, 3, 5, 3, 5, 5, 3]		, _SCREAMING_SNAKE_CASE						:		List[int] = [32, 16, 24, 40, 80, 112, 192]		, _SCREAMING_SNAKE_CASE						:		List[int] = [16, 24, 40, 80, 112, 192, 320]		, _SCREAMING_SNAKE_CASE						:		List[int] = []		, _SCREAMING_SNAKE_CASE						:		List[int] = [1, 2, 2, 2, 1, 2, 1]		, _SCREAMING_SNAKE_CASE						:		List[int] = [1, 2, 2, 3, 3, 4, 1]		, _SCREAMING_SNAKE_CASE						:		List[int] = [1, 6, 6, 6, 6, 6, 6]		, _SCREAMING_SNAKE_CASE						:		float = 0.25		, _SCREAMING_SNAKE_CASE						:		str = "swish"		, _SCREAMING_SNAKE_CASE						:		int = 2560		, _SCREAMING_SNAKE_CASE						:		str = "mean"		, _SCREAMING_SNAKE_CASE						:		float = 0.02		, _SCREAMING_SNAKE_CASE						:		float = 0.001		, _SCREAMING_SNAKE_CASE						:		float = 0.99		, _SCREAMING_SNAKE_CASE						:		float = 0.2		, **_SCREAMING_SNAKE_CASE						:		List[str]		, )->	Optional[Any]:
			super().__init__(**_SCREAMING_SNAKE_CASE		)

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




	@classmethod
	def 							UpperCAmelCase__( cls						:		Any		, _SCREAMING_SNAKE_CASE						:		Union[str, os.PathLike]		, **_SCREAMING_SNAKE_CASE						:		str		)->	"PretrainedConfig":
			cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      List[Any]   					= cls.get_config_dict(_SCREAMING_SNAKE_CASE		, **_SCREAMING_SNAKE_CASE		)

			# get the vision config dict if we are loading from AlignConfig
			if config_dict.get('''model_type'''		) == "align":
					lowerCAmelCase__       :      Optional[int]   					= 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(_SCREAMING_SNAKE_CASE		, **_SCREAMING_SNAKE_CASE		)





class  _a							(    _lowercase):
	_a  :  List[str]				   =							'''align'''
	_a  :  Tuple				   =							True




	def __init__( self						:		Any		, _SCREAMING_SNAKE_CASE						:		Any=None		, _SCREAMING_SNAKE_CASE						:		List[str]=None		, _SCREAMING_SNAKE_CASE						:		str=640		, _SCREAMING_SNAKE_CASE						:		int=1.0		, _SCREAMING_SNAKE_CASE						:		int=0.02		, **_SCREAMING_SNAKE_CASE						:		int		, )->	Union[str, Any]:
			super().__init__(**_SCREAMING_SNAKE_CASE		)

			if text_config is None:
					lowerCAmelCase__       :      Optional[Any]   					= {}
					logger.info('''text_config is None. Initializing the AlignTextConfig with default values.'''		)

			if vision_config is None:
					lowerCAmelCase__       :      Union[str, Any]   					= {}
					logger.info('''vision_config is None. Initializing the AlignVisionConfig with default values.'''		)

			lowerCAmelCase__       :      int   					= AlignTextConfig(**_SCREAMING_SNAKE_CASE		)
			lowerCAmelCase__       :      List[Any]   					= AlignVisionConfig(**_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      Any   					= projection_dim
			lowerCAmelCase__       :      int   					= temperature_init_value
			lowerCAmelCase__       :      Union[str, Any]   					= initializer_range




	@classmethod
	def 							UpperCAmelCase__( cls						:		Tuple		, _SCREAMING_SNAKE_CASE						:		AlignTextConfig		, _SCREAMING_SNAKE_CASE						:		AlignVisionConfig		, **_SCREAMING_SNAKE_CASE						:		str		)->	int:
			return cls(text_config=text_config.to_dict()		, vision_config=vision_config.to_dict()		, **_SCREAMING_SNAKE_CASE		)




	def 							UpperCAmelCase__( self						:		int		)->	Any:
			lowerCAmelCase__       :      str   					= copy.deepcopy(self.__dict__		)
			lowerCAmelCase__       :      Any   					= self.text_config.to_dict()
			lowerCAmelCase__       :      List[str]   					= self.vision_config.to_dict()
			lowerCAmelCase__       :      Tuple   					= self.__class__.model_type
			return output








import math





class  _a							:




	def __init__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		Any=0		)->	Optional[Any]:  # a graph with Node 0,1,...,N-1
			lowerCAmelCase__       :      Optional[int]   					= n
			lowerCAmelCase__       :      List[Any]   					= [
			    [math.inf for j in range(0		, _SCREAMING_SNAKE_CASE		)] for i in range(0		, _SCREAMING_SNAKE_CASE		)
			]  # adjacency matrix for weight
			lowerCAmelCase__       :      str   					= [
			    [math.inf for j in range(0		, _SCREAMING_SNAKE_CASE		)] for i in range(0		, _SCREAMING_SNAKE_CASE		)
			]  # dp[i][j] stores minimum distance from i to j




	def 							UpperCAmelCase__( self						:		Optional[Any]		, _SCREAMING_SNAKE_CASE						:		Optional[int]		, _SCREAMING_SNAKE_CASE						:		List[str]		, _SCREAMING_SNAKE_CASE						:		str		)->	List[str]:
			lowerCAmelCase__       :      Optional[int]   					= w




	def 							UpperCAmelCase__( self						:		List[Any]		)->	Optional[int]:
			for k in range(0		, self.n		):
					for i in range(0		, self.n		):
							for j in range(0		, self.n		):
									lowerCAmelCase__       :      Dict   					= min(self.dp[i][j]		, self.dp[i][k] + self.dp[k][j]		)




	def 							UpperCAmelCase__( self						:		str		, _SCREAMING_SNAKE_CASE						:		Any		, _SCREAMING_SNAKE_CASE						:		str		)->	str:
			return self.dp[u][v]


if __name__ == "__main__":
		lowerCamelCase						=		Graph(5)
		graph.add_edge(0, 2, 9)
		graph.add_edge(0, 4, 10)
		graph.add_edge(1, 3, 5)
		graph.add_edge(2, 3, 7)
		graph.add_edge(3, 0, 10)
		graph.add_edge(3, 1, 2)
		graph.add_edge(3, 2, 1)
		graph.add_edge(3, 4, 6)
		graph.add_edge(4, 1, 3)
		graph.add_edge(4, 2, 4)
		graph.add_edge(4, 3, 9)
		graph.floyd_warshall()
		graph.show_min(1, 4)
		graph.show_min(0, 3)




