


import os
import string
import sys


A			:						int        =  1 << 8

A			:						Union[str, Any]        =  {
    'tab': ord('\t'),
    'newline': ord('\r'),
    'esc': 2_7,
    'up': 6_5 + ARROW_KEY_FLAG,
    'down': 6_6 + ARROW_KEY_FLAG,
    'right': 6_7 + ARROW_KEY_FLAG,
    'left': 6_8 + ARROW_KEY_FLAG,
    'mod_int': 9_1,
    'undefined': sys.maxsize,
    'interrupt': 3,
    'insert': 5_0,
    'delete': 5_1,
    'pg_up': 5_3,
    'pg_down': 5_4,
}

A			:						List[str]        =  KEYMAP['up']
A			:						Any        =  KEYMAP['left']

if sys.platform == "win32":
	A			:						List[Any]        =  []
	A			:						Optional[Any]        =  {
	    B'\xe0H': KEYMAP['up'] - ARROW_KEY_FLAG,
	    B'\x00H': KEYMAP['up'] - ARROW_KEY_FLAG,
	    B'\xe0P': KEYMAP['down'] - ARROW_KEY_FLAG,
	    B'\x00P': KEYMAP['down'] - ARROW_KEY_FLAG,
	    B'\xe0M': KEYMAP['right'] - ARROW_KEY_FLAG,
	    B'\x00M': KEYMAP['right'] - ARROW_KEY_FLAG,
	    B'\xe0K': KEYMAP['left'] - ARROW_KEY_FLAG,
	    B'\x00K': KEYMAP['left'] - ARROW_KEY_FLAG,
	}

for i in range(1_0):
	A			:						List[Any]        =  ord(str(i))






def 					UpperCamelCase   (      )  ->    List[str]:
		"""simple docstring"""




		if os.name == "nt":
				import msvcrt

				lowercase__	     =						"""mbcs"""
				# Flush the keyboard buffer
				while msvcrt.kbhit():
						msvcrt.getch()
				if len(__magic_name__	) == 0:
						# Read the keystroke
						lowercase__	     =						msvcrt.getch()

						# If it is a prefix char, get second part
						if ch in (b"\x00", b"\xe0"):
								lowercase__	     =						ch + msvcrt.getch()
								# Translate actual Win chars to bullet char types
								try:
										lowercase__	     =						chr(WIN_KEYMAP[cha]	)
										WIN_CH_BUFFER.append(chr(KEYMAP["""mod_int"""]	)	)
										WIN_CH_BUFFER.append(__magic_name__	)
										if ord(__magic_name__	) in (
										    KEYMAP["insert"] - 1 << 9,
										    KEYMAP["delete"] - 1 << 9,
										    KEYMAP["pg_up"] - 1 << 9,
										    KEYMAP["pg_down"] - 1 << 9,
										):
												WIN_CH_BUFFER.append(chr(126	)	)
										lowercase__	     =						chr(KEYMAP["""esc"""]	)
								except KeyError:
										lowercase__	     =						cha[1]
						else:
								lowercase__	     =						ch.decode(__magic_name__	)
				else:
						lowercase__	     =						WIN_CH_BUFFER.pop(0	)
		elif os.name == "posix":
				import termios
				import tty

				lowercase__	     =						sys.stdin.fileno()
				lowercase__	     =						termios.tcgetattr(__magic_name__	)
				try:
						tty.setraw(__magic_name__	)
						lowercase__	     =						sys.stdin.read(1	)
				finally:
						termios.tcsetattr(__magic_name__       ,       termios.TCSADRAIN       ,       __magic_name__	)
		return ch







def 					UpperCamelCase   (      )  ->    Dict:
		"""simple docstring"""




		lowercase__	     =						get_raw_chars()
		if ord(__magic_name__	) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
				return char

		elif ord(__magic_name__	) == KEYMAP["esc"]:
				lowercase__	     =						get_raw_chars()
				if ord(__magic_name__	) == KEYMAP["mod_int"]:
						lowercase__	     =						get_raw_chars()
						if ord(__magic_name__	) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(__magic_name__	) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
								return chr(ord(__magic_name__	) + ARROW_KEY_FLAG	)
						else:
								return KEYMAP["undefined"]
				else:
						return get_raw_chars()

		else:
				if char in string.printable:
						return char
				else:
						return KEYMAP["undefined"]





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 				A       (			unittest.TestCase				):
					'''simple docstring'''






					A__     =					MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING

					def     lowerCamelCase__	(self       :		List[str] ,   _UpperCAmelCase       :		List[str] ,   _UpperCAmelCase       :		Dict ,   _UpperCAmelCase       :		Tuple						)		->  Tuple:




							"""simple docstring"""


							lowercase__	     =						hf_hub_download(
							    repo_id="""nateraw/video-demo""" ,   filename="""archery.mp4""" ,   repo_type="""dataset"""						)
							lowercase__	     =						VideoClassificationPipeline(model=_UpperCAmelCase ,   image_processor=_UpperCAmelCase ,   top_k=2						)
							lowercase__	     =						[
							    example_video_filepath,
							    """https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4""",
							]
							return video_classifier, examples

					def     lowerCamelCase__	(self       :		List[str] ,   _UpperCAmelCase       :		Union[str, Any] ,   _UpperCAmelCase       :		Tuple						)		->  List[Any]:




							"""simple docstring"""


							for example in examples:
									lowercase__	     =						video_classifier(_UpperCAmelCase						)

									self.assertEqual(
									    _UpperCAmelCase ,   [
									        {"""score""": ANY(_UpperCAmelCase						), """label""": ANY(_UpperCAmelCase						)},
									        {"""score""": ANY(_UpperCAmelCase						), """label""": ANY(_UpperCAmelCase						)},
									    ] ,   )

					@require_torch
					def     lowerCamelCase__	(self       :		str						)		->  List[Any]:




							"""simple docstring"""


							lowercase__	     =						"""hf-internal-testing/tiny-random-VideoMAEForVideoClassification"""
							lowercase__	     =						VideoMAEFeatureExtractor(
							    size={"""shortest_edge""": 10} ,   crop_size={"""height""": 10, """width""": 10}						)
							lowercase__	     =						pipeline(
							    """video-classification""" ,   model=_UpperCAmelCase ,   feature_extractor=_UpperCAmelCase ,   frame_sampling_rate=4						)

							lowercase__	     =						hf_hub_download(repo_id="""nateraw/video-demo""" ,   filename="""archery.mp4""" ,   repo_type="""dataset"""						)
							lowercase__	     =						video_classifier(_UpperCAmelCase ,   top_k=2						)
							self.assertEqual(
							    nested_simplify(_UpperCAmelCase ,   decimals=4						) ,   [{"""score""": 0.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}] ,   )

							lowercase__	     =						video_classifier(
							    [
							        video_file_path,
							        video_file_path,
							    ] ,   top_k=2 ,   )
							self.assertEqual(
							    nested_simplify(_UpperCAmelCase ,   decimals=4						) ,   [
							        [{"""score""": 0.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}],
							        [{"""score""": 0.5_199, """label""": """LABEL_0"""}, {"""score""": 0.4_801, """label""": """LABEL_1"""}],
							    ] ,   )


					@require_tf
					def     lowerCamelCase__	(self       :		Any						)		->  Union[str, Any]:




							"""simple docstring"""


							pass

