"""simple docstring"""





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


lowerCAmelCase_     =	logging.get_logger(__name__)

lowerCAmelCase_     =	{
    '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json''',
}




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"lxmert"
				a			=						{}





				def __init__(      self							:							Tuple      ,    _A							:							str=3_0_5_2_2      ,    _A							:							Optional[int]=7_6_8      ,    _A							:							Dict=1_2      ,    _A							:							Union[str, Any]=9_5_0_0      ,    _A							:							Union[str, Any]=1_6_0_0      ,    _A							:							Optional[Any]=4_0_0      ,    _A							:							str=3_0_7_2      ,    _A							:							Dict="gelu"      ,    _A							:							List[Any]=0.1      ,    _A							:							Tuple=0.1      ,    _A							:							Optional[int]=5_1_2      ,    _A							:							str=2      ,    _A							:							Dict=0.02      ,    _A							:							int=1e-12      ,    _A							:							List[str]=9      ,    _A							:							List[str]=5      ,    _A							:							Optional[Any]=5      ,    _A							:							List[Any]=2_0_4_8      ,    _A							:							Optional[Any]=4      ,    _A							:							Dict=6.67      ,    _A							:							Any=True      ,    _A							:							List[Any]=True      ,    _A							:							Union[str, Any]=True      ,    _A							:							Dict=True      ,    _A							:							Optional[int]=True      ,    _A							:							List[Any]=True      ,    _A							:							List[Any]=True      ,    **_A							:							int      ,    ):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Dict			  =    vocab_size
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_size
											_SCREAMING_SNAKE_CASE		:						Any			  =    num_attention_heads
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    hidden_act
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    intermediate_size
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    hidden_dropout_prob
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    attention_probs_dropout_prob
											_SCREAMING_SNAKE_CASE		:						int			  =    max_position_embeddings
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    type_vocab_size
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    initializer_range
											_SCREAMING_SNAKE_CASE		:						Dict			  =    layer_norm_eps
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    num_qa_labels
											_SCREAMING_SNAKE_CASE		:						int			  =    num_object_labels
											_SCREAMING_SNAKE_CASE		:						Dict			  =    num_attr_labels
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    l_layers
											_SCREAMING_SNAKE_CASE		:						str			  =    x_layers
											_SCREAMING_SNAKE_CASE		:						int			  =    r_layers
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    visual_feat_dim
											_SCREAMING_SNAKE_CASE		:						Dict			  =    visual_pos_dim
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    visual_loss_normalizer
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    task_matched
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    task_mask_lm
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    task_obj_predict
											_SCREAMING_SNAKE_CASE		:						str			  =    task_qa
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    visual_obj_loss
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    visual_attr_loss
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    visual_feat_loss
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    {"""vision""": r_layers, """cross_encoder""": x_layers, """language""": l_layers}
											super().__init__(**_A)



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







				"""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 		_lowerCAmelCase		(      self							:							int):



											"""simple docstring"""







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





				def 		_lowerCAmelCase		(      self							:							Optional[Any]      ,    _A							:							Tuple      ,    _A							:							List[str]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    labels
											return self.pre_processor(
											    [text] * len(_A)      ,    [f"""This example is {label}""" for label in labels]      ,    return_tensors="""pt"""      ,    padding="""max_length"""      ,    )





				def 		_lowerCAmelCase		(      self							:							Tuple      ,    _A							:							Optional[Any]):



											"""simple docstring"""







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


