
"""simple docstring"""




import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow







@is_pipeline_test
@require_torch
class     lowercase(unittest.TestCase       ):



     @require_torch
     def 			lowercase__  (							self   )		->     Optional[Any]:







         """simple docstring"""



         a__		=			pipeline(
             task='zero-shot-audio-classification'     ,				model='hf-internal-testing/tiny-clap-htsat-unfused'   )
         a__		=			load_dataset('ashraq/esc50'   )
         a__		=			dataset['train']['audio'][-1]['array']
         a__		=			audio_classifier(__SCREAMING_SNAKE_CASE     ,				candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )
         self.assertEqual(
             nested_simplify(__SCREAMING_SNAKE_CASE   )     ,				[{'score': 0.5_01, 'label': 'Sound of a dog'}, {'score': 0.4_99, 'label': 'Sound of vaccum cleaner'}]     ,				)



     @unittest.skip('No models are available in TF'   )
     def 			lowercase__  (							self   )		->     Any:







         """simple docstring"""



         pass



     @slow
     @require_torch
     def 			lowercase__  (							self   )		->     int:







         """simple docstring"""



         a__		=			pipeline(
             task='zero-shot-audio-classification'     ,				model='laion/clap-htsat-unfused'     ,				)
         # This is an audio of a dog
         a__		=			load_dataset('ashraq/esc50'   )
         a__		=			dataset['train']['audio'][-1]['array']
         a__		=			audio_classifier(__SCREAMING_SNAKE_CASE     ,				candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )

         self.assertEqual(
             nested_simplify(__SCREAMING_SNAKE_CASE   )     ,				[
                 {'score': 0.9_99, 'label': 'Sound of a dog'},
                 {'score': 0.0_01, 'label': 'Sound of vaccum cleaner'},
             ]     ,				)

         a__		=			audio_classifier([audio] * 5     ,				candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )
         self.assertEqual(
             nested_simplify(__SCREAMING_SNAKE_CASE   )     ,				[
                 [
                     {'score': 0.9_99, 'label': 'Sound of a dog'},
                     {'score': 0.0_01, 'label': 'Sound of vaccum cleaner'},
                 ],
             ]
             * 5     ,				)
         a__		=			audio_classifier(
             [audio] * 5     ,				candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']     ,				batch_size=5   )
         self.assertEqual(
             nested_simplify(__SCREAMING_SNAKE_CASE   )     ,				[
                 [
                     {'score': 0.9_99, 'label': 'Sound of a dog'},
                     {'score': 0.0_01, 'label': 'Sound of vaccum cleaner'},
                 ],
             ]
             * 5     ,				)




     @unittest.skip('No models are available in TF'   )
     def 			lowercase__  (							self   )		->     str:







         """simple docstring"""



         pass




"""simple docstring"""




import operator



def     __magic_name__		(					UpperCamelCase     :		list							,		UpperCamelCase     :		bool = False							,		UpperCamelCase     :		list | None = None     )     ->						list:
    a__		=			operator.lt if reverse else operator.gt
    a__		=			solution or []

    if not arr:
        return solution

    a__		=			[arr.pop(0     )]
    for i, item in enumerate(UpperCamelCase     ):
        if _operator(UpperCamelCase							,		sublist[-1]     ):
            sublist.append(UpperCamelCase     )
            arr.pop(UpperCamelCase     )

    #  merging sublist into solution list
    if not solution:
        solution.extend(UpperCamelCase     )
    else:
        while sublist:
            a__		=			sublist.pop(0     )
            for i, xx in enumerate(UpperCamelCase     ):
                if not _operator(UpperCamelCase							,		UpperCamelCase     ):
                    solution.insert(UpperCamelCase							,		UpperCamelCase     )
                    break
            else:
                solution.append(UpperCamelCase     )

    strand_sort(UpperCamelCase							,		UpperCamelCase							,		UpperCamelCase     )
    return solution


if __name__ == "__main__":
    assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
    assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]


