
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      A_				(			self							:   Optional[int]							):
						SCREAMING_SNAKE_CASE__													= pipeline(
						    task='zero-shot-audio-classification'       ,   model='hf-internal-testing/tiny-clap-htsat-unfused'							)
						SCREAMING_SNAKE_CASE__													= load_dataset('ashraq/esc50'							)
						SCREAMING_SNAKE_CASE__													= dataset['train']['audio'][-1]['array']
						SCREAMING_SNAKE_CASE__													= audio_classifier(UpperCAmelCase_       ,   candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']							)
						self.assertEqual(
						    nested_simplify(UpperCAmelCase_							)       ,   [{'score': 0.501, 'label': 'Sound of a dog'}, {'score': 0.499, 'label': 'Sound of vaccum cleaner'}]       ,   )
	@unittest.skip('No models are available in TF'							)
	def      A_				(			self							:   Dict							):
						pass
	@slow
	@require_torch
	def      A_				(			self							:   str							):
						SCREAMING_SNAKE_CASE__													= pipeline(
						    task='zero-shot-audio-classification'       ,   model='laion/clap-htsat-unfused'       ,   )
						# This is an audio of a dog
						SCREAMING_SNAKE_CASE__													= load_dataset('ashraq/esc50'							)
						SCREAMING_SNAKE_CASE__													= dataset['train']['audio'][-1]['array']
						SCREAMING_SNAKE_CASE__													= audio_classifier(UpperCAmelCase_       ,   candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']							)

						self.assertEqual(
						    nested_simplify(UpperCAmelCase_							)       ,   [
						        {'score': 0.999, 'label': 'Sound of a dog'},
						        {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
						    ]       ,   )

						SCREAMING_SNAKE_CASE__													= audio_classifier([audio] * 5       ,   candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']							)
						self.assertEqual(
						    nested_simplify(UpperCAmelCase_							)       ,   [
						        [
						            {'score': 0.999, 'label': 'Sound of a dog'},
						            {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
						        ],
						    ]
						    * 5       ,   )
						SCREAMING_SNAKE_CASE__													= audio_classifier(
						    [audio] * 5       ,   candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']       ,   batch_size=5							)
						self.assertEqual(
						    nested_simplify(UpperCAmelCase_							)       ,   [
						        [
						            {'score': 0.999, 'label': 'Sound of a dog'},
						            {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
						        ],
						    ]
						    * 5       ,   )





	@unittest.skip('No models are available in TF'							)
	def      A_				(			self							:   Tuple							):
						pass







def 							_lowercase							(     UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)		->		int:
					'''simple docstring'''


					def update_area_of_max_square(UpperCamelCase_	,	UpperCamelCase_		) -> int:
										# BASE CASE
										if row >= rows or col >= cols:
															return 0

										SCREAMING_SNAKE_CASE__													= update_area_of_max_square(UpperCamelCase_	,	col + 1		)
										SCREAMING_SNAKE_CASE__													= update_area_of_max_square(row + 1	,	col + 1		)
										SCREAMING_SNAKE_CASE__													= update_area_of_max_square(row + 1	,	UpperCamelCase_		)

										if mat[row][col]:
															SCREAMING_SNAKE_CASE__													= 1 + min([right, diagonal, down]		)
															SCREAMING_SNAKE_CASE__													= max(largest_square_area[0]	,	UpperCamelCase_		)
															return sub_problem_sol
										else:
															return 0

					SCREAMING_SNAKE_CASE__													= [0]
					update_area_of_max_square(0	,	0		)
					return largest_square_area[0]






def 							_lowercase							(     UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)		->		int:
					'''simple docstring'''


					def update_area_of_max_square_using_dp_array(
					    UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		) -> int:
										if row >= rows or col >= cols:
															return 0
										if dp_array[row][col] != -1:
															return dp_array[row][col]

										SCREAMING_SNAKE_CASE__													= update_area_of_max_square_using_dp_array(UpperCamelCase_	,	col + 1	,	UpperCamelCase_		)
										SCREAMING_SNAKE_CASE__													= update_area_of_max_square_using_dp_array(row + 1	,	col + 1	,	UpperCamelCase_		)
										SCREAMING_SNAKE_CASE__													= update_area_of_max_square_using_dp_array(row + 1	,	UpperCamelCase_	,	UpperCamelCase_		)

										if mat[row][col]:
															SCREAMING_SNAKE_CASE__													= 1 + min([right, diagonal, down]		)
															SCREAMING_SNAKE_CASE__													= max(largest_square_area[0]	,	UpperCamelCase_		)
															SCREAMING_SNAKE_CASE__													= sub_problem_sol
															return sub_problem_sol
										else:
															return 0

					SCREAMING_SNAKE_CASE__													= [0]
					SCREAMING_SNAKE_CASE__													= [[-1] * cols for _ in range(UpperCamelCase_		)]
					update_area_of_max_square_using_dp_array(0	,	0	,	UpperCamelCase_		)

					return largest_square_area[0]






def 							_lowercase							(     UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)		->		int:
					'''simple docstring'''


					SCREAMING_SNAKE_CASE__													= [[0] * (cols + 1) for _ in range(rows + 1		)]
					SCREAMING_SNAKE_CASE__													= 0
					for row in range(rows - 1	,	-1	,	-1		):
										for col in range(cols - 1	,	-1	,	-1		):
															SCREAMING_SNAKE_CASE__													= dp_array[row][col + 1]
															SCREAMING_SNAKE_CASE__													= dp_array[row + 1][col + 1]
															SCREAMING_SNAKE_CASE__													= dp_array[row + 1][col]

															if mat[row][col] == 1:
																				SCREAMING_SNAKE_CASE__													= 1 + min(UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)
																				SCREAMING_SNAKE_CASE__													= max(dp_array[row][col]	,	UpperCamelCase_		)
															else:
																				SCREAMING_SNAKE_CASE__													= 0

					return largest_square_area






def 							_lowercase							(     UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)		->		int:
					'''simple docstring'''


					SCREAMING_SNAKE_CASE__													= [0] * (cols + 1)
					SCREAMING_SNAKE_CASE__													= [0] * (cols + 1)
					SCREAMING_SNAKE_CASE__													= 0
					for row in range(rows - 1	,	-1	,	-1		):
										for col in range(cols - 1	,	-1	,	-1		):
															SCREAMING_SNAKE_CASE__													= current_row[col + 1]
															SCREAMING_SNAKE_CASE__													= next_row[col + 1]
															SCREAMING_SNAKE_CASE__													= next_row[col]

															if mat[row][col] == 1:
																				SCREAMING_SNAKE_CASE__													= 1 + min(UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)
																				SCREAMING_SNAKE_CASE__													= max(current_row[col]	,	UpperCamelCase_		)
															else:
																				SCREAMING_SNAKE_CASE__													= 0
										SCREAMING_SNAKE_CASE__													= current_row

					return largest_square_area


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				print(largest_square_area_in_matrix_bottom_up(2, 2, [[1, 1], [1, 1]]))





