





"""simple docstring"""



from typing import List, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


a_ =			logging.get_logger(__name__)

a_ =			{
    """huggingface/time-series-transformer-tourism-monthly""": (
        """https://huggingface.co/huggingface/time-series-transformer-tourism-monthly/resolve/main/config.json"""
    ),
    # See all TimeSeriesTransformer models at https://huggingface.co/models?filter=time_series_transformer
}






class 		__snake_case					(		SCREAMING_SNAKE_CASE__     ):





 """simple docstring"""


 _lowerCamelCase        =     """time_series_transformer"""
 _lowerCamelCase        =     {
     """hidden_size""": """d_model""",
     """num_attention_heads""": """encoder_attention_heads""",
     """num_hidden_layers""": """encoder_layers""",
 }

 def __init__(    self					,						__lowerCamelCase = None					,						__lowerCamelCase = None					,						__lowerCamelCase = "student_t"					,						__lowerCamelCase = "nll"					,						__lowerCamelCase = 1					,						__lowerCamelCase = [1, 2, 3, 4, 5, 6, 7]					,						__lowerCamelCase = "mean"					,						__lowerCamelCase = 0					,						__lowerCamelCase = 0					,						__lowerCamelCase = 0					,						__lowerCamelCase = 0					,						__lowerCamelCase = None					,						__lowerCamelCase = None					,						__lowerCamelCase = 32					,						__lowerCamelCase = 32					,						__lowerCamelCase = 2					,						__lowerCamelCase = 2					,						__lowerCamelCase = 2					,						__lowerCamelCase = 2					,						__lowerCamelCase = True					,						__lowerCamelCase = "gelu"					,						__lowerCamelCase = 64					,						__lowerCamelCase = 0.1					,						__lowerCamelCase = 0.1					,						__lowerCamelCase = 0.1					,						__lowerCamelCase = 0.1					,						__lowerCamelCase = 0.1					,						__lowerCamelCase = 100					,						__lowerCamelCase = 0.0_2					,						__lowerCamelCase=True					,						**__lowerCamelCase					,						):



     '''simple docstring'''




     __A    :						Optional[Any]						 =     prediction_length
     __A    :						Tuple						 =     context_length or prediction_length
     __A    :						Any						 =     distribution_output
     __A    :						int						 =     loss
     __A    :						Any						 =     input_size
     __A    :						List[str]						 =     num_time_features
     __A    :						Union[str, Any]						 =     lags_sequence
     __A    :						str						 =     scaling
     __A    :						str						 =     num_dynamic_real_features
     __A    :						int						 =     num_static_real_features
     __A    :						int						 =     num_static_categorical_features
     if cardinality and num_static_categorical_features > 0:
         if len(__lowerCamelCase  ) != num_static_categorical_features:
             raise ValueError(
                 '''The cardinality should be a list of the same length as `num_static_categorical_features`'''  )
         __A    :						int						 =     cardinality
     else:
         __A    :						Dict						 =     [0]
     if embedding_dimension and num_static_categorical_features > 0:
         if len(__lowerCamelCase  ) != num_static_categorical_features:
             raise ValueError(
                 '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''  )
         __A    :						List[Any]						 =     embedding_dimension
     else:
         __A    :						Union[str, Any]						 =     [min(50					,						(cat + 1) // 2  ) for cat in self.cardinality]
     __A    :						Optional[Any]						 =     num_parallel_samples

     # Transformer architecture configuration
     __A    :						str						 =     input_size * len(__lowerCamelCase  ) + self._number_of_features
     __A    :						List[Any]						 =     d_model
     __A    :						Optional[Any]						 =     encoder_attention_heads
     __A    :						Optional[Any]						 =     decoder_attention_heads
     __A    :						Tuple						 =     encoder_ffn_dim
     __A    :						int						 =     decoder_ffn_dim
     __A    :						Union[str, Any]						 =     encoder_layers
     __A    :						int						 =     decoder_layers

     __A    :						int						 =     dropout
     __A    :						str						 =     attention_dropout
     __A    :						List[str]						 =     activation_dropout
     __A    :						Tuple						 =     encoder_layerdrop
     __A    :						List[Any]						 =     decoder_layerdrop

     __A    :						str						 =     activation_function
     __A    :						Any						 =     init_std

     __A    :						str						 =     use_cache

     super().__init__(is_encoder_decoder=__lowerCamelCase					,						**__lowerCamelCase  )







 @property
 def 					UpperCamelCase__(    self  ):



     '''simple docstring'''




     return (
         sum(self.embedding_dimension  )
         + self.num_dynamic_real_features
         + self.num_time_features
         + self.num_static_real_features
         + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
     )











"""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 		__snake_case					(		SCREAMING_SNAKE_CASE__     ):





 """simple docstring"""


 _lowerCamelCase        =     """facebook/bart-large-mnli"""
 _lowerCamelCase        =     (
     """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."""
 )
 _lowerCamelCase        =     """text_classifier"""
 _lowerCamelCase        =     AutoTokenizer
 _lowerCamelCase        =     AutoModelForSequenceClassification

 _lowerCamelCase        =     ["""text""", ["""text"""]]
 _lowerCamelCase        =     ["""text"""]

 def 					UpperCamelCase__(    self  ):



     '''simple docstring'''




     super().setup()
     __A    :						List[str]						 =     self.model.config
     __A    :						int						 =     -1
     for idx, label in config.idalabel.items():
         if label.lower().startswith('''entail'''  ):
             __A    :						List[str]						 =     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  ):



     '''simple docstring'''




     __A    :						Union[str, Any]						 =     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  ):



     '''simple docstring'''




     __A    :						List[Any]						 =     outputs.logits
     __A    :						List[str]						 =     torch.argmax(logits[:, 2]  ).item()
     return self._labels[label_id]




