


def     UpperCamelCase    (      _a		)					->							str:
     '''simple docstring'''





     lowercase_       :Dict     =       ''''''
     for ch in key:
          if ch == " " or ch not in key_no_dups and ch.isalpha():
               key_no_dups += ch
     return key_no_dups




def     UpperCamelCase    (      _a		)					->							dict[str, str]:
     '''simple docstring'''





     lowercase_       :Union[str, Any]     =       [chr(i + 6_5		) for i in range(2_6		)]
     # Remove duplicate characters from key
     lowercase_       :Union[str, Any]     =       remove_duplicates(key.upper()		)
     lowercase_       :Any     =       len(_a		)
     # First fill cipher with key characters
     lowercase_       :List[Any]     =       {alphabet[i]: char for i, char in enumerate(_a		)}
     # Then map remaining characters in alphabet to
     # the alphabet from the beginning
     for i in range(len(_a		)       ,		2_6		):
          lowercase_       :str     =       alphabet[i - offset]
          # Ensure we are not mapping letters to letters previously mapped
          while char in key:
               offset -= 1
               lowercase_       :Union[str, Any]     =       alphabet[i - offset]
          lowercase_       :str     =       char
     return cipher_alphabet




def     UpperCamelCase    (      _a       ,		_a		)					->							str:
     '''simple docstring'''





     return "".join(cipher_map.get(_a       ,		_a		) for ch in message.upper()		)




def     UpperCamelCase    (      _a       ,		_a		)					->							str:
     '''simple docstring'''





     lowercase_       :Optional[Any]     =       {v: k for k, v in cipher_map.items()}
     return "".join(rev_cipher_map.get(_a       ,		_a		) for ch in message.upper()		)




def     UpperCamelCase    (      )					->							None:
     '''simple docstring'''





     lowercase_       :Any     =       input('''Enter message to encode or decode: '''		).strip()
     lowercase_       :List[Any]     =       input('''Enter keyword: '''		).strip()
     lowercase_       :Optional[Any]     =       input('''Encipher or decipher? E/D:'''		).strip()[0].lower()
     try:
          lowercase_       :List[str]     =       {'''e''': encipher, '''d''': decipher}[option]
     except KeyError:
          raise KeyError('''invalid input option'''		)
     lowercase_       :Optional[int]     =       create_cipher_map(_a		)
     print(func(_a       ,		_a		)		)


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   main()





from io import BytesIO
from typing import List, Union

import requests

from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_decord_available():
   import numpy as np
   from decord import VideoReader


if is_torch_available():
   from ..models.auto.modeling_auto import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING

SCREAMING_SNAKE_CASE       :		List[str]         =				logging.get_logger(__name__)






@add_end_docstrings(lowercase__     )
class      UpperCamelCase					(		lowercase__     ):


   '''simple docstring'''







   def __init__(     self   ,							*UpperCamelCase_   ,							**UpperCamelCase_		):
        super().__init__(*UpperCamelCase_   ,							**UpperCamelCase_		)
        requires_backends(self   ,							'''decord'''		)
        self.check_model_type(UpperCamelCase_		)
   def 		UpperCamelCase  (     self   ,							UpperCamelCase_=None   ,							UpperCamelCase_=None   ,							UpperCamelCase_=None		):
        lowercase_       :int     =       {}
        if frame_sampling_rate is not None:
             lowercase_       :int     =       frame_sampling_rate
        if num_frames is not None:
             lowercase_       :int     =       num_frames

        lowercase_       :str     =       {}
        if top_k is not None:
             lowercase_       :Optional[int]     =       top_k
        return preprocess_params, {}, postprocess_params
   def __call__(     self   ,							UpperCamelCase_   ,							**UpperCamelCase_		):
        return super().__call__(UpperCamelCase_   ,							**UpperCamelCase_		)
   def 		UpperCamelCase  (     self   ,							UpperCamelCase_   ,							UpperCamelCase_=None   ,							UpperCamelCase_=1		):
        if num_frames is None:
             lowercase_       :str     =       self.model.config.num_frames

        if video.startswith('''http://'''		) or video.startswith('''https://'''		):
             lowercase_       :str     =       BytesIO(requests.get(UpperCamelCase_		).content		)

        lowercase_       :Optional[int]     =       VideoReader(UpperCamelCase_		)
        videoreader.seek(0		)

        lowercase_       :Tuple     =       0
        lowercase_       :Optional[Any]     =       num_frames * frame_sampling_rate - 1
        lowercase_       :Any     =       np.linspace(UpperCamelCase_   ,							UpperCamelCase_   ,							num=UpperCamelCase_   ,							dtype=np.intaa		)

        lowercase_       :Dict     =       videoreader.get_batch(UpperCamelCase_		).asnumpy()
        lowercase_       :List[Any]     =       list(UpperCamelCase_		)

        lowercase_       :Any     =       self.image_processor(UpperCamelCase_   ,							return_tensors=self.framework		)
        return model_inputs
   def 		UpperCamelCase  (     self   ,							UpperCamelCase_		):
        lowercase_       :List[str]     =       self.model(**UpperCamelCase_		)
        return model_outputs




   def 		UpperCamelCase  (     self   ,							UpperCamelCase_   ,							UpperCamelCase_=5		):
        if top_k > self.model.config.num_labels:
             lowercase_       :List[str]     =       self.model.config.num_labels

        if self.framework == "pt":
             lowercase_       :Optional[int]     =       model_outputs.logits.softmax(-1		)[0]
             lowercase_    ,      lowercase_       :Dict     =       probs.topk(UpperCamelCase_		)
        else:
             raise ValueError(f"Unsupported framework: {self.framework}"		)

        lowercase_       :Dict     =       scores.tolist()
        lowercase_       :Any     =       ids.tolist()
        return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(UpperCamelCase_   ,							UpperCamelCase_		)]

