'''simple docstring'''





def      __lowerCAmelCase    (							a_							,   a_		)   ->						int:





     '''simple docstring'''





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


def      __lowerCAmelCase    (							a_							,   a_=0		)   ->						Union[str, Any]:





     '''simple docstring'''





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


def      __lowerCAmelCase    (							a_							,   a_							,   a_=float('inf'		)		)   ->						Union[str, Any]:





     '''simple docstring'''





     for i in range(points_counts - 1		):
          for j in range(i + 1							,   a_		):
               SCREAMING_SNAKE_CASE       :      List[Any]     						=							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_							,   a_							,   a_=float('inf'		)		)   ->						Dict:





     '''simple docstring'''





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


def      __lowerCAmelCase    (							a_							,   a_							,   a_		)   ->						List[Any]:





     '''simple docstring'''





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

     # recursion
     SCREAMING_SNAKE_CASE       :      Any     						=							points_counts // 2
     SCREAMING_SNAKE_CASE       :      Optional[Any]     						=							closest_pair_of_points_sqr(
         a_							,   points_sorted_on_y[:mid]							,   a_		)
     SCREAMING_SNAKE_CASE       :      Optional[int]     						=							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       :      List[str]     						=							dis_between_closest_in_strip(
         a_							,   len(a_		)							,   a_		)
     return min(a_							,   a_		)


def      __lowerCAmelCase    (							a_							,   a_		)   ->						Tuple:





     '''simple docstring'''





     SCREAMING_SNAKE_CASE       :      str     						=							column_based_sort(a_							,   column=0		)
     SCREAMING_SNAKE_CASE       :      Optional[Any]     						=							column_based_sort(a_							,   column=1		)
     return (
         closest_pair_of_points_sqr(
             a_							,   a_							,   a_		)
     ) ** 0.5


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











import unittest

import numpy as np

from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING
from transformers.pipelines import AudioClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_torchaudio,
    slow,
)

from .test_pipelines_common import ANY




@is_pipeline_test
class 					UpperCamelCase_ (     unittest.TestCase							):



	'''simple docstring'''




	lowerCAmelCase						=					MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING
	lowerCAmelCase						=					TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING




	def 				_UpperCamelCase     (			self			,     a			,     a			,     a   )			->       Union[str, Any]:
								snake_case_           =				AudioClassificationPipeline(model=a			,     feature_extractor=a   )

								# test with a raw waveform
								snake_case_           =				np.zeros((3_40_00,)   )
								snake_case_           =				np.zeros((1_40_00,)   )
								return audio_classifier, [audioa, audio]




	def 				_UpperCamelCase     (			self			,     a			,     a   )			->       Tuple:
								snake_case_     ,						snake_case_           =				examples
								snake_case_           =				audio_classifier(a   )
								# by default a model is initialized with num_labels=2
								self.assertEqual(
								    a			,     [
								        {'score': ANY(a   ), 'label': ANY(a   )},
								        {'score': ANY(a   ), 'label': ANY(a   )},
								    ]			,     )
								snake_case_           =				audio_classifier(a			,     top_k=1   )
								self.assertEqual(
								    a			,     [
								        {'score': ANY(a   ), 'label': ANY(a   )},
								    ]			,     )

								self.run_torchaudio(a   )




	@require_torchaudio
	def 				_UpperCamelCase     (			self			,     a   )			->       List[str]:
								import datasets

								# test with a local file
								snake_case_           =				datasets.load_dataset('hf-internal-testing/librispeech_asr_dummy'			,     'clean'			,     split='validation'   )
								snake_case_           =				dataset[0]['audio']['array']
								snake_case_           =				audio_classifier(a   )
								self.assertEqual(
								    a			,     [
								        {'score': ANY(a   ), 'label': ANY(a   )},
								        {'score': ANY(a   ), 'label': ANY(a   )},
								    ]			,     )




	@require_torch
	def 				_UpperCamelCase     (			self   )			->       Dict:
								snake_case_           =				'anton-l/wav2vec2-random-tiny-classifier'

								snake_case_           =				pipeline('audio-classification'			,     model=a   )

								snake_case_           =				np.ones((80_00,)   )
								snake_case_           =				audio_classifier(a			,     top_k=4   )

								snake_case_           =				[
								    {'score': 0.0_842, 'label': 'no'},
								    {'score': 0.0_838, 'label': 'up'},
								    {'score': 0.0_837, 'label': 'go'},
								    {'score': 0.0_834, 'label': 'right'},
								]
								snake_case_           =				[
								    {'score': 0.0_845, 'label': 'stop'},
								    {'score': 0.0_844, 'label': 'on'},
								    {'score': 0.0_841, 'label': 'right'},
								    {'score': 0.0_834, 'label': 'left'},
								]
								self.assertIn(nested_simplify(a			,     decimals=4   )			,     [EXPECTED_OUTPUT, EXPECTED_OUTPUT_PT_2]   )

								snake_case_           =				{'array': np.ones((80_00,)   ), 'sampling_rate': audio_classifier.feature_extractor.sampling_rate}
								snake_case_           =				audio_classifier(a			,     top_k=4   )
								self.assertIn(nested_simplify(a			,     decimals=4   )			,     [EXPECTED_OUTPUT, EXPECTED_OUTPUT_PT_2]   )




	@require_torch
	@slow
	def 				_UpperCamelCase     (			self   )			->       str:
								import datasets

								snake_case_           =				'superb/wav2vec2-base-superb-ks'

								snake_case_           =				pipeline('audio-classification'			,     model=a   )
								snake_case_           =				datasets.load_dataset('anton-l/superb_dummy'			,     'ks'			,     split='test'   )

								snake_case_           =				np.array(dataset[3]['speech']			,     dtype=np.floataa   )
								snake_case_           =				audio_classifier(a			,     top_k=4   )
								self.assertEqual(
								    nested_simplify(a			,     decimals=3   )			,     [
								        {'score': 0.981, 'label': 'go'},
								        {'score': 0.007, 'label': 'up'},
								        {'score': 0.006, 'label': '_unknown_'},
								        {'score': 0.001, 'label': 'down'},
								    ]			,     )






	@require_tf
	@unittest.skip('Audio classification is not implemented for TF'   )
	def 				_UpperCamelCase     (			self   )			->       Optional[int]:
								pass





