




import functools
import operator

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


__a          =			logging.get_logger(__name__)

__a          =			{
    'microsoft/unispeech-large-1500h-cv': (
        'https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json'
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}

class   __a(					_a       ):






    """simple docstring"""





    lowerCAmelCase        =				'''unispeech'''





    def __init__(				self       ,_SCREAMING_SNAKE_CASE=32       ,_SCREAMING_SNAKE_CASE=768       ,_SCREAMING_SNAKE_CASE=12       ,_SCREAMING_SNAKE_CASE=12       ,_SCREAMING_SNAKE_CASE=3_072       ,_SCREAMING_SNAKE_CASE="gelu"       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE=0.0       ,_SCREAMING_SNAKE_CASE=0.0       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE=0.02       ,_SCREAMING_SNAKE_CASE=1e-5       ,_SCREAMING_SNAKE_CASE="group"       ,_SCREAMING_SNAKE_CASE="gelu"       ,_SCREAMING_SNAKE_CASE=(512, 512, 512, 512, 512, 512, 512)       ,_SCREAMING_SNAKE_CASE=(5, 2, 2, 2, 2, 2, 2)       ,_SCREAMING_SNAKE_CASE=(10, 3, 3, 3, 3, 2, 2)       ,_SCREAMING_SNAKE_CASE=False       ,_SCREAMING_SNAKE_CASE=128       ,_SCREAMING_SNAKE_CASE=16       ,_SCREAMING_SNAKE_CASE=False       ,_SCREAMING_SNAKE_CASE=True       ,_SCREAMING_SNAKE_CASE=0.05       ,_SCREAMING_SNAKE_CASE=10       ,_SCREAMING_SNAKE_CASE=2       ,_SCREAMING_SNAKE_CASE=0.0       ,_SCREAMING_SNAKE_CASE=10       ,_SCREAMING_SNAKE_CASE=0       ,_SCREAMING_SNAKE_CASE=320       ,_SCREAMING_SNAKE_CASE=2       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE=100       ,_SCREAMING_SNAKE_CASE=256       ,_SCREAMING_SNAKE_CASE=256       ,_SCREAMING_SNAKE_CASE=0.1       ,_SCREAMING_SNAKE_CASE="mean"       ,_SCREAMING_SNAKE_CASE=False       ,_SCREAMING_SNAKE_CASE=False       ,_SCREAMING_SNAKE_CASE=256       ,_SCREAMING_SNAKE_CASE=80       ,_SCREAMING_SNAKE_CASE=0       ,_SCREAMING_SNAKE_CASE=1       ,_SCREAMING_SNAKE_CASE=2       ,_SCREAMING_SNAKE_CASE=0.5       ,**_SCREAMING_SNAKE_CASE       ,)			->		Optional[int]:
         super().__init__(**_SCREAMING_SNAKE_CASE       ,pad_token_id=_SCREAMING_SNAKE_CASE       ,bos_token_id=_SCREAMING_SNAKE_CASE       ,eos_token_id=_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Union[str, Any]       =      hidden_size
         UpperCAmelCase_      :							Union[str, Any]       =      feat_extract_norm
         UpperCAmelCase_      :							Tuple       =      feat_extract_activation
         UpperCAmelCase_      :							List[Any]       =      list(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Dict       =      list(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Optional[int]       =      list(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[Any]       =      conv_bias
         UpperCAmelCase_      :							Optional[int]       =      num_conv_pos_embeddings
         UpperCAmelCase_      :							str       =      num_conv_pos_embedding_groups
         UpperCAmelCase_      :							Tuple       =      len(self.conv_dim  )
         UpperCAmelCase_      :							Dict       =      num_hidden_layers
         UpperCAmelCase_      :							List[Any]       =      intermediate_size
         UpperCAmelCase_      :							Tuple       =      hidden_act
         UpperCAmelCase_      :							Optional[Any]       =      num_attention_heads
         UpperCAmelCase_      :							List[Any]       =      hidden_dropout
         UpperCAmelCase_      :							str       =      attention_dropout
         UpperCAmelCase_      :							int       =      activation_dropout
         UpperCAmelCase_      :							str       =      feat_proj_dropout
         UpperCAmelCase_      :							Dict       =      final_dropout
         UpperCAmelCase_      :							Dict       =      layerdrop
         UpperCAmelCase_      :							Union[str, Any]       =      layer_norm_eps
         UpperCAmelCase_      :							Tuple       =      initializer_range
         UpperCAmelCase_      :							Tuple       =      num_ctc_classes
         UpperCAmelCase_      :							Any       =      vocab_size
         UpperCAmelCase_      :							Union[str, Any]       =      do_stable_layer_norm
         UpperCAmelCase_      :							List[Any]       =      use_weighted_layer_sum
         UpperCAmelCase_      :							Any       =      classifier_proj_size

         if (
             (len(self.conv_stride  ) != self.num_feat_extract_layers)
             or (len(self.conv_kernel  ) != self.num_feat_extract_layers)
             or (len(self.conv_dim  ) != self.num_feat_extract_layers)
         ):
              raise ValueError(
                  '''Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='''
                  ''' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='''
                  f''' {len(self.conv_dim  )}`, `len(config.conv_stride) = {len(self.conv_stride  )}`,'''
                  f''' `len(config.conv_kernel) = {len(self.conv_kernel  )}`.'''  )

         # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
         UpperCAmelCase_      :							Union[str, Any]       =      apply_spec_augment
         UpperCAmelCase_      :							Any       =      mask_time_prob
         UpperCAmelCase_      :							Any       =      mask_time_length
         UpperCAmelCase_      :							Union[str, Any]       =      mask_time_min_masks
         UpperCAmelCase_      :							str       =      mask_feature_prob
         UpperCAmelCase_      :							Dict       =      mask_feature_length
         UpperCAmelCase_      :							Union[str, Any]       =      mask_feature_min_masks

         # parameters for pretraining with codevector quantized representations
         UpperCAmelCase_      :							Optional[int]       =      num_codevectors_per_group
         UpperCAmelCase_      :							str       =      num_codevector_groups
         UpperCAmelCase_      :							Tuple       =      contrastive_logits_temperature
         UpperCAmelCase_      :							Union[str, Any]       =      feat_quantizer_dropout
         UpperCAmelCase_      :							Any       =      num_negatives
         UpperCAmelCase_      :							Dict       =      codevector_dim
         UpperCAmelCase_      :							Tuple       =      proj_codevector_dim
         UpperCAmelCase_      :							Optional[Any]       =      diversity_loss_weight

         # ctc loss
         UpperCAmelCase_      :							List[Any]       =      ctc_loss_reduction
         UpperCAmelCase_      :							Tuple       =      ctc_zero_infinity

         # pretraining loss
         UpperCAmelCase_      :							List[Any]       =      replace_prob





    @property
    def 							a__				(				self  )			->		Optional[Any]:
         return functools.reduce(operator.mul       ,self.conv_stride       ,1  )





def lowerCamelCase__       (      _lowercase			,						_lowercase				):

     '''simple docstring'''


     return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2







def lowerCamelCase__       (      _lowercase			,						_lowercase=0				):

     '''simple docstring'''


     return sorted(_lowercase			,						key=lambda _lowercase				: x[column]				)







def lowerCamelCase__       (      _lowercase			,						_lowercase			,						_lowercase=float('''inf'''				)				):

     '''simple docstring'''


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







def lowerCamelCase__       (      _lowercase			,						_lowercase			,						_lowercase=float('''inf'''				)				):

     '''simple docstring'''


     for i in range(min(6			,						points_counts - 1				)			,						_lowercase				):
          for j in range(max(0			,						i - 6				)			,						_lowercase				):
               UpperCAmelCase_      :							List[str]       =      euclidean_distance_sqr(points[i]			,						points[j]				)
               if current_dis < min_dis:
                    UpperCAmelCase_      :							Optional[int]       =      current_dis
     return min_dis







def lowerCamelCase__       (      _lowercase			,						_lowercase			,						_lowercase				):

     '''simple docstring'''


     if points_counts <= 3:
          return dis_between_closest_pair(_lowercase			,						_lowercase				)

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

     UpperCAmelCase_      :							Optional[Any]       =      dis_between_closest_in_strip(
         _lowercase			,						len(_lowercase				)			,						_lowercase				)
     return min(_lowercase			,						_lowercase				)







def lowerCamelCase__       (      _lowercase			,						_lowercase				):

     '''simple docstring'''


     UpperCAmelCase_      :							Tuple       =      column_based_sort(_lowercase			,						column=0				)
     UpperCAmelCase_      :							List[Any]       =      column_based_sort(_lowercase			,						column=1				)
     return (
         closest_pair_of_points_sqr(
             _lowercase			,						_lowercase			,						_lowercase				)
     ) ** 0.5


if __name__ == "__main__":
     __a          =			[(2, 3), (12, 30), (40, 50), (5, 1), (12, 10), (3, 4)]
     print('Distance:', closest_pair_of_points(points, len(points)))