



import os
import string
import sys


a_								=    1 << 8

a_								=    {
    """tab""": ord("""\t"""),
    """newline""": ord("""\r"""),
    """esc""": 27,
    """up""": 65 + ARROW_KEY_FLAG,
    """down""": 66 + ARROW_KEY_FLAG,
    """right""": 67 + ARROW_KEY_FLAG,
    """left""": 68 + ARROW_KEY_FLAG,
    """mod_int""": 91,
    """undefined""": sys.maxsize,
    """interrupt""": 3,
    """insert""": 50,
    """delete""": 51,
    """pg_up""": 53,
    """pg_down""": 54,
}

a_								=    KEYMAP["""up"""]
a_								=    KEYMAP["""left"""]

if sys.platform == "win32":
  a_								=    []
  a_								=    {
      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(10):
  a_								=    ord(str(i))





def 						a__	(						):


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

      __lowerCamelCase  							=			'''mbcs'''
      # Flush the keyboard buffer
      while msvcrt.kbhit():
         msvcrt.getch()
      if len(_UpperCamelCase							) == 0:
         # Read the keystroke
         __lowerCamelCase  							=			msvcrt.getch()

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

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





def 						a__	(						):
   __lowerCamelCase  							=			get_raw_chars()
   if ord(_UpperCamelCase							) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
      return char

   elif ord(_UpperCamelCase							) == KEYMAP["esc"]:
      __lowerCamelCase  							=			get_raw_chars()
      if ord(_UpperCamelCase							) == KEYMAP["mod_int"]:
         __lowerCamelCase  							=			get_raw_chars()
         if ord(_UpperCamelCase							) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(_UpperCamelCase							) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
            return chr(ord(_UpperCamelCase							) + 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 					__lowerCAmelCase       (			unittest.TestCase     ):
			lowerCamelCase_     :     Any       			=      MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING






			def 			lowerCamelCase  (self					,							__magic_name__					,							__magic_name__					,							__magic_name__    )     ->   Dict:


							'''simple docstring'''



							snake_case_						:    Any				=  hf_hub_download(
							    repo_id='''nateraw/video-demo'''					,							filename='''archery.mp4'''					,							repo_type='''dataset'''    )
							snake_case_						:    List[Any]				=  VideoClassificationPipeline(model=__magic_name__					,							image_processor=__magic_name__					,							top_k=2    )
							snake_case_						:    str				=  [
							    example_video_filepath,
							    '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
							]
							return video_classifier, examples






			def 			lowerCamelCase  (self					,							__magic_name__					,							__magic_name__    )     ->   Any:


							'''simple docstring'''



							for example in examples:
											snake_case_						:    Union[str, Any]				=  video_classifier(__magic_name__    )

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






			@require_torch
			def 			lowerCamelCase  (self    )     ->   str:


							'''simple docstring'''



							snake_case_						:    Any				=  '''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
							snake_case_						:    str				=  VideoMAEFeatureExtractor(
							    size={'''shortest_edge''': 10}					,							crop_size={'''height''': 10, '''width''': 10}    )
							snake_case_						:    int				=  pipeline(
							    '''video-classification'''					,							model=__magic_name__					,							feature_extractor=__magic_name__					,							frame_sampling_rate=4    )

							snake_case_						:    List[str]				=  hf_hub_download(repo_id='''nateraw/video-demo'''					,							filename='''archery.mp4'''					,							repo_type='''dataset'''    )
							snake_case_						:    Union[str, Any]				=  video_classifier(__magic_name__					,							top_k=2    )
							self.assertEqual(
							    nested_simplify(__magic_name__					,							decimals=4    )					,							[{'''score''': 0.5_199, '''label''': '''LABEL_0'''}, {'''score''': 0.4_801, '''label''': '''LABEL_1'''}]					,							)

							snake_case_						:    int				=  video_classifier(
							    [
							        video_file_path,
							        video_file_path,
							    ]					,							top_k=2					,							)
							self.assertEqual(
							    nested_simplify(__magic_name__					,							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    )     ->   Optional[int]:


							'''simple docstring'''



							pass
