






'''simple docstring'''



import torch

from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer
from .base import PipelineTool
class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):
      __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  __UpperCamelCase							(  self      )							->Optional[int]:



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




      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase      )							->List[Any]:



         '''simple docstring'''
         __a				     =    labels
         return self.pre_processor(
             [text] * len(lowerCamelCase      ) ,   [F"""This example is {label}""" for label in labels] ,   return_tensors='pt' ,   padding='max_length' ,   )






      def  __UpperCamelCase							(  self ,   lowerCamelCase      )							->List[str]:



         '''simple docstring'''
         __a				     =    outputs.logits
         __a				     =    torch.argmax(logits[:, 2]      ).item()
         return self._labels[label_id]







'''simple docstring'''



from maths.prime_factors import prime_factors



def    __UpperCAmelCase	(				SCREAMING_SNAKE_CASE__:	int    )  ->			int:

   """simple docstring"""
   if not isinstance(SCREAMING_SNAKE_CASE__,					SCREAMING_SNAKE_CASE__    ):
      __a				     =    f"""Input value of [number={number}] must be an integer"""
      raise TypeError(SCREAMING_SNAKE_CASE__    )
   if number < 1:
      raise ValueError('Input must be a positive integer'    )
   return -1 if len(prime_factors(SCREAMING_SNAKE_CASE__    )    ) % 2 else 1


if __name__ == "__main__":
 import doctest

 doctest.testmod()