






'''simple docstring'''
import os
import string
import sys


a_					=	1 << 8

a_					=	{
    '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_					=	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(1_0):
  a_					=	ord(str(i))





def 	_a(					):




      '''simple docstring'''






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

            SCREAMING_SNAKE_CASE__       :			List[Any]													='''mbcs'''
            # Flush the keyboard buffer
            while msvcrt.kbhit():
                  msvcrt.getch()
            if len(UpperCamelCase__							) == 0:
                  # Read the keystroke
                  SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=msvcrt.getch()

                  # If it is a prefix char, get second part
                  if ch in (b"\x00", b"\xe0"):
                        SCREAMING_SNAKE_CASE__       :			str													=ch + msvcrt.getch()
                        # Translate actual Win chars to bullet char types
                        try:
                              SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=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_2_6							)							)
                              SCREAMING_SNAKE_CASE__       :			List[str]													=chr(KEYMAP['''esc''']							)
                        except KeyError:
                              SCREAMING_SNAKE_CASE__       :			Tuple													=cha[1]
                  else:
                        SCREAMING_SNAKE_CASE__       :			List[str]													=ch.decode(UpperCamelCase__							)
            else:
                  SCREAMING_SNAKE_CASE__       :			Dict													=WIN_CH_BUFFER.pop(0							)
      elif os.name == "posix":
            import termios
            import tty

            SCREAMING_SNAKE_CASE__       :			Dict													=sys.stdin.fileno()
            SCREAMING_SNAKE_CASE__       :			int													=termios.tcgetattr(UpperCamelCase__							)
            try:
                  tty.setraw(UpperCamelCase__							)
                  SCREAMING_SNAKE_CASE__       :			Tuple													=sys.stdin.read(1							)
            finally:
                  termios.tcsetattr(UpperCamelCase__,		termios.TCSADRAIN,		UpperCamelCase__							)
      return ch







def 	_a(					):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			Tuple													=get_raw_chars()
      if ord(UpperCamelCase__							) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
            return char

      elif ord(UpperCamelCase__							) == KEYMAP["esc"]:
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=get_raw_chars()
            if ord(UpperCamelCase__							) == KEYMAP["mod_int"]:
                  SCREAMING_SNAKE_CASE__       :			int													=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"]







'''simple docstring'''
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import torch

from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer
from .base import PipelineTool






class        __SCREAMING_SNAKE_CASE (     lowerCamelCase			):
 snake_case_												=							"""facebook/bart-large-mnli"""
 snake_case_												=							(
     """This is a tool that classifies an English text using provided labels. It takes two inputs: `text`, which """
     """should be the text to classify, and `labels`, which should be the list of labels to use for classification. """
     """It returns the most likely label in the list of provided `labels` for the input text."""
 )
 snake_case_												=							"""text_classifier"""
 snake_case_												=							AutoTokenizer
 snake_case_												=							AutoModelForSequenceClassification

 snake_case_												=							["""text""", ["""text"""]]
 snake_case_												=							["""text"""]




 def        __magic_name__		( self		:							Any )		->  Any:
       super().setup()
       SCREAMING_SNAKE_CASE__       :			int													=self.model.config
       SCREAMING_SNAKE_CASE__       :			int													=-1
       for idx, label in config.idalabel.items():
             if label.lower().startswith('''entail''' ):
                   SCREAMING_SNAKE_CASE__       :			Any													=int(__lowercase )
       if self.entailment_id == -1:
             raise ValueError('''Could not determine the entailment ID from the model config, please pass it at init.''' )




 def        __magic_name__		( self		:							str   , __lowercase		:							Any   , __lowercase		:							Optional[Any] )		->  Optional[Any]:
       SCREAMING_SNAKE_CASE__       :			Dict													=labels
       return self.pre_processor(
           [text] * len(__lowercase )   , [F"This example is {label}" for label in labels]   , return_tensors='''pt'''   , padding='''max_length'''   , )




 def        __magic_name__		( self		:							List[Any]   , __lowercase		:							str )		->  List[Any]:
       SCREAMING_SNAKE_CASE__       :			int													=outputs.logits
       SCREAMING_SNAKE_CASE__       :			Any													=torch.argmax(logits[:, 2] ).item()
       return self._labels[label_id]