


import unittest

from huggingface_hub import hf_hub_download

from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
from transformers.pipelines import VideoClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_decord,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
)

from .test_pipelines_common import ANY







@is_pipeline_test
@require_torch_or_tf
@require_vision
@require_decord
class 				snake_case__(							unittest.TestCase							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  int					=							MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    Tuple:
										lowerCAmelCase_ :      int    				=				hf_hub_download(
										    repo_id='''nateraw/video-demo'''   ,						filename='''archery.mp4'''   ,						repo_type='''dataset'''							)
										lowerCAmelCase_ :      str    				=				VideoClassificationPipeline(model=__lowercase   ,						image_processor=__lowercase   ,						top_k=2							)
										lowerCAmelCase_ :      Dict    				=				[
										    example_video_filepath,
										    '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
										]
										return video_classifier, examples




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase							)					->    Tuple:
										for example in examples:
														lowerCAmelCase_ :      List[Any]    				=				video_classifier(__lowercase							)

														self.assertEqual(
														    __lowercase   ,						[
														        {'''score''': ANY(__lowercase							), '''label''': ANY(__lowercase							)},
														        {'''score''': ANY(__lowercase							), '''label''': ANY(__lowercase							)},
														    ]   ,						)




						@require_torch
						def 						lowercase_ (				self							)					->    Any:
										lowerCAmelCase_ :      Dict    				=				'''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
										lowerCAmelCase_ :      Dict    				=				VideoMAEFeatureExtractor(
										    size={'''shortest_edge''': 1_0}   ,						crop_size={'''height''': 1_0, '''width''': 1_0}							)
										lowerCAmelCase_ :      Dict    				=				pipeline(
										    '''video-classification'''   ,						model=__lowercase   ,						feature_extractor=__lowercase   ,						frame_sampling_rate=4							)

										lowerCAmelCase_ :      Any    				=				hf_hub_download(repo_id='''nateraw/video-demo'''   ,						filename='''archery.mp4'''   ,						repo_type='''dataset'''							)
										lowerCAmelCase_ :      Dict    				=				video_classifier(__lowercase   ,						top_k=2							)
										self.assertEqual(
										    nested_simplify(__lowercase   ,						decimals=4							)   ,						[{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}]   ,						)

										lowerCAmelCase_ :      Optional[Any]    				=				video_classifier(
										    [
										        video_file_path,
										        video_file_path,
										    ]   ,						top_k=2   ,						)
										self.assertEqual(
										    nested_simplify(__lowercase   ,						decimals=4							)   ,						[
										        [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}],
										        [{'''score''': 0.51_99, '''label''': '''LABEL_0'''}, {'''score''': 0.48_01, '''label''': '''LABEL_1'''}],
										    ]   ,						)




						@require_tf
						def 						lowercase_ (				self							)					->    str:
										pass



from __future__ import annotations



def 			lowerCAmelCase (		lowerCAmelCase_ ,   lowerCAmelCase_ ,   lowerCAmelCase_ ,   )-> tuple:
				if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1:
								raise ValueError('''You cannot supply more or less than 2 values''' )
				elif electron_conc < 0:
								raise ValueError('''Electron concentration cannot be negative in a semiconductor''' )
				elif hole_conc < 0:
								raise ValueError('''Hole concentration cannot be negative in a semiconductor''' )
				elif intrinsic_conc < 0:
								raise ValueError(
								    '''Intrinsic concentration cannot be negative in a semiconductor''' )
				elif electron_conc == 0:
								return (
								    "electron_conc",
								    intrinsic_conc**2 / hole_conc,
								)
				elif hole_conc == 0:
								return (
								    "hole_conc",
								    intrinsic_conc**2 / electron_conc,
								)
				elif intrinsic_conc == 0:
								return (
								    "intrinsic_conc",
								    (electron_conc * hole_conc) ** 0.5,
								)
				else:
								return (-1, -1)


if __name__ == "__main__":
						import doctest

						doctest.testmod()