


import doctest
from collections import deque

import numpy as np






class     UpperCAmelCase__       :



    """simple docstring"""






    def __init__(			self    )  ->       None:
         __UpperCamelCase    							=[2, 1, 2, -1]
         __UpperCamelCase    							=[1, 2, 3, 4]






    def _a					(			self    )  ->       list[float]:
         __UpperCamelCase    							=len(self.first_signal    )
         __UpperCamelCase    							=len(self.second_signal    )

         __UpperCamelCase    							=max(A_					,   A_    )

         # create a zero matrix of max_length x max_length
         __UpperCamelCase    							=[[0] * max_length for i in range(A_    )]

         # fills the smaller signal with zeros to make both signals of same length
         if length_first_signal < length_second_signal:
              self.first_signal += [0] * (max_length - length_first_signal)
         elif length_first_signal > length_second_signal:
              self.second_signal += [0] * (max_length - length_second_signal)
         for i in range(A_    ):
              __UpperCamelCase    							=deque(self.second_signal    )
              rotated_signal.rotate(A_    )
              for j, item in enumerate(A_    ):
                   matrix[i][j] += item

        # multiply the matrix with the first signal
         __UpperCamelCase    							=np.matmul(np.transpose(A_    )					,   np.transpose(self.first_signal    )    )

         # rounding-off to two decimal places
         return [round(A_					,   2    ) for i in final_signal]


if __name__ == "__main__":
   doctest.testmod()






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   snake_case_       (		unittest.TestCase       ):






   @require_torch
   def       __UpperCamelCase     (      self				:     Optional[int]  )					->						List[Any]:
       lowercase__ :   Union[str, Any]    					=				pipeline(
           task="zero-shot-audio-classification"	,						model="hf-internal-testing/tiny-clap-htsat-unfused"  )
       lowercase__ :   List[str]    					=				load_dataset("ashraq/esc50"  )
       lowercase__ :   List[Any]    					=				dataset["train"]["audio"][-1]["array"]
       lowercase__ :   Dict    					=				audio_classifier(lowercase_	,						candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]  )
       self.assertEqual(
           nested_simplify(lowercase_  )	,						[{"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       __UpperCamelCase     (      self				:     str  )					->						Optional[int]:
       pass






   @slow
   @require_torch
   def       __UpperCamelCase     (      self				:     List[str]  )					->						int:
       lowercase__ :   Tuple    					=				pipeline(
           task="zero-shot-audio-classification"	,						model="laion/clap-htsat-unfused"	,						)
       # This is an audio of a dog
       lowercase__ :   Union[str, Any]    					=				load_dataset("ashraq/esc50"  )
       lowercase__ :   Tuple    					=				dataset["train"]["audio"][-1]["array"]
       lowercase__ :   List[Any]    					=				audio_classifier(lowercase_	,						candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]  )

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

       lowercase__ :   int    					=				audio_classifier([audio] * 5	,						candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]  )
       self.assertEqual(
           nested_simplify(lowercase_  )	,						[
               [
                   {"score": 0.9_99, "label": "Sound of a dog"},
                   {"score": 0.0_01, "label": "Sound of vaccum cleaner"},
               ],
           ]
           * 5	,						)
       lowercase__ :   Tuple    					=				audio_classifier(
           [audio] * 5	,						candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]	,						batch_size=5  )
       self.assertEqual(
           nested_simplify(lowercase_  )	,						[
               [
                   {"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       __UpperCamelCase     (      self				:     Union[str, Any]  )					->						Dict:
       pass



