





"""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


lowerCamelCase_       =		logging.get_logger(__name__)

lowerCamelCase_       =		{
    "kakaobrain/align-base": "https://huggingface.co/kakaobrain/align-base/resolve/main/config.json",
}






class  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				Dict     						=  '''align_text_model'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=3_05_22		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=30_72		,SCREAMING_SNAKE_CASE__="gelu"		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=5_12		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1E-12		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__="absolute"		,SCREAMING_SNAKE_CASE__=True		,**SCREAMING_SNAKE_CASE__		,)      ->				List[str]:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)

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




       @classmethod
       def    _UpperCamelCase					(						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				"PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :Union[str, 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":
                   __SCREAMING_SNAKE_CASE       :int		    =  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  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				Optional[Any]     						=  '''align_vision_model'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__ = 3		,SCREAMING_SNAKE_CASE__ = 6_00		,SCREAMING_SNAKE_CASE__ = 2.0		,SCREAMING_SNAKE_CASE__ = 3.1		,SCREAMING_SNAKE_CASE__ = 8		,SCREAMING_SNAKE_CASE__ = [3, 3, 5, 3, 5, 5, 3]		,SCREAMING_SNAKE_CASE__ = [32, 16, 24, 40, 80, 1_12, 1_92]		,SCREAMING_SNAKE_CASE__ = [16, 24, 40, 80, 1_12, 1_92, 3_20]		,SCREAMING_SNAKE_CASE__ = []		,SCREAMING_SNAKE_CASE__ = [1, 2, 2, 2, 1, 2, 1]		,SCREAMING_SNAKE_CASE__ = [1, 2, 2, 3, 3, 4, 1]		,SCREAMING_SNAKE_CASE__ = [1, 6, 6, 6, 6, 6, 6]		,SCREAMING_SNAKE_CASE__ = 0.2_5		,SCREAMING_SNAKE_CASE__ = "swish"		,SCREAMING_SNAKE_CASE__ = 25_60		,SCREAMING_SNAKE_CASE__ = "mean"		,SCREAMING_SNAKE_CASE__ = 0.0_2		,SCREAMING_SNAKE_CASE__ = 0.0_0_1		,SCREAMING_SNAKE_CASE__ = 0.9_9		,SCREAMING_SNAKE_CASE__ = 0.2		,**SCREAMING_SNAKE_CASE__		,)      ->				str:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)

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




       @classmethod
       def    _UpperCamelCase					(						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				"PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :Tuple		    =  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":
                   __SCREAMING_SNAKE_CASE       :List[str]		    =  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  _SCREAMING_SNAKE_CASE(       A  ):
       SCREAMING_SNAKE_CASE_       :				Optional[Any]     						=  '''align'''
       SCREAMING_SNAKE_CASE_       :				int     						=  True




       def __init__(						self		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=6_40		,SCREAMING_SNAKE_CASE__=1.0		,SCREAMING_SNAKE_CASE__=0.0_2		,**SCREAMING_SNAKE_CASE__		,)      ->				Any:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)

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

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

             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  AlignTextConfig(**SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE       :Any		    =  AlignVisionConfig(**SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE       :Any		    =  projection_dim
             __SCREAMING_SNAKE_CASE       :str		    =  temperature_init_value
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  initializer_range




       @classmethod
       def    _UpperCamelCase					(						cls		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)      ->				Any:





             """simple docstring"""






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




       def    _UpperCamelCase					(						self							)      ->				str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :int		    =  copy.deepcopy(self.__dict__							)
             __SCREAMING_SNAKE_CASE       :str		    =  self.text_config.to_dict()
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  self.vision_config.to_dict()
             __SCREAMING_SNAKE_CASE       :str		    =  self.__class__.model_type
             return output






"""simple docstring"""
def 					__lowerCamelCase       (							a_					:		Union[str, Any]			,       a_					:		Optional[Any]							)      ->				Union[str, Any]:
      return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2



def 					__lowerCamelCase       (							a_					:		Optional[int]			,       a_					:		Any=0							)      ->				Optional[Any]:
      return sorted(a_			,       key=lambda a_							: x[column]							)



def 					__lowerCamelCase       (							a_					:		Optional[Any]			,       a_					:		Optional[int]			,       a_					:		str=float('''inf'''							)							)      ->				str:

      for i in range(points_counts - 1							):
            for j in range(i + 1			,       a_							):
                  __SCREAMING_SNAKE_CASE       :Dict		    =  euclidean_distance_sqr(points[i]			,       points[j]							)
                  if current_dis < min_dis:
                        __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  current_dis
      return min_dis



def 					__lowerCamelCase       (							a_					:		List[Any]			,       a_					:		Any			,       a_					:		Optional[int]=float('''inf'''							)							)      ->				Optional[Any]:

      for i in range(min(6			,       points_counts - 1							)			,       a_							):
            for j in range(max(0			,       i - 6							)			,       a_							):
                  __SCREAMING_SNAKE_CASE       :Dict		    =  euclidean_distance_sqr(points[i]			,       points[j]							)
                  if current_dis < min_dis:
                        __SCREAMING_SNAKE_CASE       :int		    =  current_dis
      return min_dis



def 					__lowerCamelCase       (							a_					:		str			,       a_					:		List[Any]			,       a_					:		int							)      ->				Optional[int]:

      # base case
      if points_counts <= 3:
            return dis_between_closest_pair(a_			,       a_							)

      # recursion
      __SCREAMING_SNAKE_CASE       :int		    =  points_counts // 2
      __SCREAMING_SNAKE_CASE       :Dict		    =  closest_pair_of_points_sqr(
          a_			,       points_sorted_on_y[:mid]			,       a_							)
      __SCREAMING_SNAKE_CASE       :Any		    =  closest_pair_of_points_sqr(
          a_			,       points_sorted_on_y[mid:]			,       points_counts - mid							)
      __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  min(a_			,       a_							)
      __SCREAMING_SNAKE_CASE       :str		    =  []
      for point in points_sorted_on_x:
            if abs(point[0] - points_sorted_on_x[mid][0]							) < closest_pair_dis:
                  cross_strip.append(a_							)

      __SCREAMING_SNAKE_CASE       :Dict		    =  dis_between_closest_in_strip(
          a_			,       len(a_							)			,       a_							)
      return min(a_			,       a_							)



def 					__lowerCamelCase       (							a_					:		int			,       a_					:		Tuple							)      ->				List[Any]:
      __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  column_based_sort(a_			,       column=0							)
      __SCREAMING_SNAKE_CASE       :int		    =  column_based_sort(a_			,       column=1							)
      return (
          closest_pair_of_points_sqr(
              a_			,       a_			,       a_							)
      ) ** 0.5


if __name__ == "__main__":
  lowerCamelCase_       =		[(2, 3), (1_2, 3_0), (4_0, 5_0), (5, 1), (1_2, 1_0), (3, 4)]
  print("Distance:", closest_pair_of_points(points, len(points)))