


'''simple docstring'''







import torch

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


class 			__lowerCamelCase			(	__a	):
    """simple docstring"""
    a													=   "facebook/bart-large-mnli"
    a													=   (
        "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."
    )
    a													=   "text_classifier"
    a													=   AutoTokenizer
    a													=   AutoModelForSequenceClassification

    a													=   ["text", ["text"]]
    a													=   ["text"]


    def        A   (  self      :							Optional[Any]):
           super().setup()
           _A					:     str     = self.model.config
           _A					:     int     = -1
           for idx, label in config.idalabel.items():
                  if label.lower().startswith('entail'):
                         _A					:     Any     = int(UpperCamelCase__)
           if self.entailment_id == -1:
                  raise ValueError('Could not determine the entailment ID from the model config, please pass it at init.')


    def        A   (  self      :							Optional[Any]				,							SCREAMING_SNAKE_CASE      :							List[str]				,							SCREAMING_SNAKE_CASE      :							Any):
           _A					:     str     = labels
           return self.pre_processor(
               [text] * len(UpperCamelCase__)				,							[F'This example is {label}' for label in labels]				,							return_tensors='pt'				,							padding='max_length'				,							)


    def        A   (  self      :							Optional[Any]				,							SCREAMING_SNAKE_CASE      :							Any):
           _A					:     Dict     = outputs.logits
           _A					:     List[str]     = torch.argmax(logits[:, 2]).item()
           return self._labels[label_id]










'''simple docstring'''







import operator as op


A				:					List[str]    						=			'''scaler.pt'''
A				:					Optional[int]    						=			'''pytorch_model'''
A				:					Union[str, Any]    						=			'''random_states'''
A				:					List[Any]    						=			'''optimizer'''
A				:					Optional[Any]    						=			'''scheduler'''
A				:					Optional[int]    						=			'''pytorch_model.bin'''
A				:					List[str]    						=			'''pytorch_model.bin.index.json'''
A				:					List[Any]    						=			'''model.safetensors'''
A				:					int    						=			'''model.safetensors.index.json'''
A				:					List[str]    						=			'''1.10.2'''
A				:					str    						=			'''py38'''
A				:					int    						=			'''4.17.0'''
A				:					Tuple    						=			['''ml.p3.16xlarge''', '''ml.p3dn.24xlarge''', '''ml.p4dn.24xlarge''']
A				:					Union[str, Any]    						=			['''FULL_SHARD''', '''SHARD_GRAD_OP''', '''NO_SHARD''', '''HYBRID_SHARD''', '''HYBRID_SHARD_ZERO2''']
A				:					Optional[Any]    						=			['''TRANSFORMER_BASED_WRAP''', '''SIZE_BASED_WRAP''', '''NO_WRAP''']
A				:					Dict    						=			['''BACKWARD_PRE''', '''BACKWARD_POST''', '''NO_PREFETCH''']
A				:					Any    						=			['''FULL_STATE_DICT''', '''LOCAL_STATE_DICT''', '''SHARDED_STATE_DICT''']
A				:					Tuple    						=			'''2.0.1'''
A				:					List[str]    						=			['''pdsh''', '''standard''', '''openmpi''', '''mvapich''']
A				:					Union[str, Any]    						=			['''default''', '''reduce-overhead''', '''max-autotune''']

A				:					List[Any]    						=			{'''>''': op.gt, '''>=''': op.ge, '''==''': op.eq, '''!=''': op.ne, '''<=''': op.le, '''<''': op.lt}

# These are the args for `torch.distributed.launch` for pytorch < 1.9
A				:					Tuple    						=			[
    '''nnodes''',
    '''nproc_per_node''',
    '''rdzv_backend''',
    '''rdzv_endpoint''',
    '''rdzv_id''',
    '''rdzv_conf''',
    '''standalone''',
    '''max_restarts''',
    '''monitor_interval''',
    '''start_method''',
    '''role''',
    '''module''',
    '''m''',
    '''no_python''',
    '''run_path''',
    '''log_dir''',
    '''r''',
    '''redirects''',
    '''t''',
    '''tee''',
    '''node_rank''',
    '''master_addr''',
    '''master_port''',
]

A				:					List[str]    						=			['''DEEPSPEED''', '''MULTI_GPU''', '''FSDP''', '''MEGATRON_LM''']
A				:					Any    						=			['''DEEPSPEED''', '''MULTI_XPU''', '''FSDP''']






