





"""simple docstring"""
from __future__ import annotations

import math



def 					__lowerCamelCase       (							a_					:		list			,       a_					:		list							)      ->				List[Any]:
      if len(lowerCAmelCase__							) != 2 or len(a[0]							) != 2 or len(lowerCAmelCase__							) != 2 or len(b[0]							) != 2:
            raise Exception('''Matrices are not 2x2'''							)
      __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  [
          [a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],
          [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]],
      ]
      return new_matrix



def 					__lowerCamelCase       (							a_					:		list			,       a_					:		list							)      ->				Tuple:
      return [
          [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]							)							)]
          for row in range(len(lowerCAmelCase__							)							)
      ]



def 					__lowerCamelCase       (							a_					:		list			,       a_					:		list							)      ->				Tuple:
      return [
          [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]							)							)]
          for row in range(len(lowerCAmelCase__							)							)
      ]



def 					__lowerCamelCase       (							a_					:		list							)      ->				List[Any]:
      if len(lowerCAmelCase__							) % 2 != 0 or len(a[0]							) % 2 != 0:
            raise Exception('''Odd matrices are not supported!'''							)

      __SCREAMING_SNAKE_CASE       :List[Any]		    =  len(lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :str		    =  matrix_length // 2

      __SCREAMING_SNAKE_CASE       :int		    =  [[a[i][j] for j in range(lowerCAmelCase__			,       lowerCAmelCase__							)] for i in range(lowerCAmelCase__							)]
      __SCREAMING_SNAKE_CASE       :Any		    =  [
          [a[i][j] for j in range(lowerCAmelCase__			,       lowerCAmelCase__							)] for i in range(lowerCAmelCase__			,       lowerCAmelCase__							)
      ]

      __SCREAMING_SNAKE_CASE       :Tuple		    =  [[a[i][j] for j in range(lowerCAmelCase__							)] for i in range(lowerCAmelCase__							)]
      __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  [[a[i][j] for j in range(lowerCAmelCase__							)] for i in range(lowerCAmelCase__			,       lowerCAmelCase__							)]

      return top_left, top_right, bot_left, bot_right



def 					__lowerCamelCase       (							a_					:		list							)      ->				Optional[int]:
      return len(lowerCAmelCase__							), len(matrix[0]							)



def 					__lowerCamelCase       (							a_					:		list							)      ->				List[Any]:
      print('''\n'''.join(str(lowerCAmelCase__							) for line in matrix							)							)



def 					__lowerCamelCase       (							a_					:		list			,       a_					:		list							)      ->				Optional[int]:
      if matrix_dimensions(lowerCAmelCase__							) == (2, 2):
            return default_matrix_multiplication(lowerCAmelCase__			,       lowerCAmelCase__							)

      __SCREAMING_SNAKE_CASE       :Tuple		    =  split_matrix(lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :List[Any]		    =  split_matrix(lowerCAmelCase__							)

      __SCREAMING_SNAKE_CASE       :List[str]		    =  actual_strassen(lowerCAmelCase__			,       matrix_subtraction(lowerCAmelCase__			,       lowerCAmelCase__							)							)
      __SCREAMING_SNAKE_CASE       :Dict		    =  actual_strassen(matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)			,       lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :Tuple		    =  actual_strassen(matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)			,       lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :Dict		    =  actual_strassen(lowerCAmelCase__			,       matrix_subtraction(lowerCAmelCase__			,       lowerCAmelCase__							)							)
      __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  actual_strassen(matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)			,       matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)							)
      __SCREAMING_SNAKE_CASE       :List[str]		    =  actual_strassen(matrix_subtraction(lowerCAmelCase__			,       lowerCAmelCase__							)			,       matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)							)
      __SCREAMING_SNAKE_CASE       :Optional[int]		    =  actual_strassen(matrix_subtraction(lowerCAmelCase__			,       lowerCAmelCase__							)			,       matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)							)

      __SCREAMING_SNAKE_CASE       :int		    =  matrix_addition(matrix_subtraction(matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)			,       lowerCAmelCase__							)			,       lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :str		    =  matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :Tuple		    =  matrix_subtraction(matrix_subtraction(matrix_addition(lowerCAmelCase__			,       lowerCAmelCase__							)			,       lowerCAmelCase__							)			,       lowerCAmelCase__							)

      # construct the new matrix from our 4 quadrants
      __SCREAMING_SNAKE_CASE       :str		    =  []
      for i in range(len(lowerCAmelCase__							)							):
            new_matrix.append(top_left[i] + top_right[i]							)
      for i in range(len(lowerCAmelCase__							)							):
            new_matrix.append(bot_left[i] + bot_right[i]							)
      return new_matrix



def 					__lowerCamelCase       (							a_					:		list			,       a_					:		list							)      ->				Any:
      if matrix_dimensions(lowerCAmelCase__							)[1] != matrix_dimensions(lowerCAmelCase__							)[0]:
            __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  (
                '''Unable to multiply these matrices, please check the dimensions.\n'''
                f'''Matrix A: {matrixa}\n'''
                f'''Matrix B: {matrixa}'''
            )
            raise Exception(lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :Tuple		    =  matrix_dimensions(lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  matrix_dimensions(lowerCAmelCase__							)

      if dimensiona[0] == dimensiona[1] and dimensiona[0] == dimensiona[1]:
            return [matrixa, matrixa]

      __SCREAMING_SNAKE_CASE       :Any		    =  max(*lowerCAmelCase__			,       *lowerCAmelCase__							)
      __SCREAMING_SNAKE_CASE       :List[Any]		    =  int(math.pow(2			,       math.ceil(math.loga(lowerCAmelCase__							)							)							)							)
      __SCREAMING_SNAKE_CASE       :Tuple		    =  matrixa
      __SCREAMING_SNAKE_CASE       :Any		    =  matrixa

      # Adding zeros to the matrices so that the arrays dimensions are the same and also
      # power of 2
      for i in range(0			,       lowerCAmelCase__							):
            if i < dimensiona[0]:
                  for _ in range(dimensiona[1]			,       lowerCAmelCase__							):
                        new_matrixa[i].append(0							)
            else:
                  new_matrixa.append([0] * maxim							)
            if i < dimensiona[0]:
                  for _ in range(dimensiona[1]			,       lowerCAmelCase__							):
                        new_matrixa[i].append(0							)
            else:
                  new_matrixa.append([0] * maxim							)

      __SCREAMING_SNAKE_CASE       :str		    =  actual_strassen(lowerCAmelCase__			,       lowerCAmelCase__							)

      # Removing the additional zeros
      for i in range(0			,       lowerCAmelCase__							):
            if i < dimensiona[0]:
                  for _ in range(dimensiona[1]			,       lowerCAmelCase__							):
                        final_matrix[i].pop()
            else:
                  final_matrix.pop()
      return final_matrix


if __name__ == "__main__":
  lowerCamelCase_       =		[
      [2, 3, 4, 5],
      [6, 4, 3, 1],
      [2, 3, 6, 7],
      [3, 1, 2, 4],
      [2, 3, 4, 5],
      [6, 4, 3, 1],
      [2, 3, 6, 7],
      [3, 1, 2, 4],
      [2, 3, 4, 5],
      [6, 2, 3, 1],
  ]
  lowerCamelCase_       =		[[0, 2, 1, 1], [1_6, 2, 3, 3], [2, 2, 7, 7], [1_3, 1_1, 2_2, 4]]
  print(strassen(matrixa, matrixa))










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




       @require_torch
       def    _UpperCamelCase					(						self							)      ->				str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Dict		    =  pipeline(
                 task='''zero-shot-audio-classification'''		,model='''hf-internal-testing/tiny-clap-htsat-unfused'''							)
             __SCREAMING_SNAKE_CASE       :Any		    =  load_dataset('''ashraq/esc50'''							)
             __SCREAMING_SNAKE_CASE       :int		    =  dataset['''train''']['''audio'''][-1]['''array''']
             __SCREAMING_SNAKE_CASE       :Dict		    =  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_0_1, '''label''': '''Sound of a dog'''}, {'''score''': 0.4_9_9, '''label''': '''Sound of vaccum cleaner'''}]		,)




       @unittest.skip('''No models are available in TF'''							)
       def    _UpperCamelCase					(						self							)      ->				Optional[int]:





             """simple docstring"""






             pass




       @slow
       @require_torch
       def    _UpperCamelCase					(						self							)      ->				Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  pipeline(
                 task='''zero-shot-audio-classification'''		,model='''laion/clap-htsat-unfused'''		,)
             # This is an audio of a dog
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  load_dataset('''ashraq/esc50'''							)
             __SCREAMING_SNAKE_CASE       :Tuple		    =  dataset['''train''']['''audio'''][-1]['''array''']
             __SCREAMING_SNAKE_CASE       :str		    =  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_9_9, '''label''': '''Sound of a dog'''},
                     {'''score''': 0.0_0_1, '''label''': '''Sound of vaccum cleaner'''},
                 ]		,)

             __SCREAMING_SNAKE_CASE       :Dict		    =  audio_classifier([audio] * 5		,candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']							)
             self.assertEqual(
                 nested_simplify(SCREAMING_SNAKE_CASE__							)		,[
                     [
                         {'''score''': 0.9_9_9, '''label''': '''Sound of a dog'''},
                         {'''score''': 0.0_0_1, '''label''': '''Sound of vaccum cleaner'''},
                     ],
                 ]
                 * 5		,)
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  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_9_9, '''label''': '''Sound of a dog'''},
                         {'''score''': 0.0_0_1, '''label''': '''Sound of vaccum cleaner'''},
                     ],
                 ]
                 * 5		,)




       @unittest.skip('''No models are available in TF'''							)
       def    _UpperCamelCase					(						self							)      ->				List[str]:





             """simple docstring"""






             pass