






'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


a_					=	logging.get_logger(__name__)

a_					=	{
    'microsoft/beit-base-patch16-224-pt22k': (
        'https://huggingface.co/microsoft/beit-base-patch16-224-pt22k/resolve/main/config.json'
    ),
    # See all BEiT models at https://huggingface.co/models?filter=beit
}






class        __SCREAMING_SNAKE_CASE (     lowerCamelCase			):
 snake_case_												=							"""beit"""




 def __init__( self		:							Dict   , __lowercase		:							List[str]=81_92   , __lowercase		:							str=7_68   , __lowercase		:							Optional[Any]=12   , __lowercase		:							Dict=12   , __lowercase		:							List[str]=30_72   , __lowercase		:							Dict="gelu"   , __lowercase		:							List[Any]=0.0   , __lowercase		:							Any=0.0   , __lowercase		:							str=0.02   , __lowercase		:							Union[str, Any]=1e-12   , __lowercase		:							Dict=2_24   , __lowercase		:							List[Any]=16   , __lowercase		:							Dict=3   , __lowercase		:							str=False   , __lowercase		:							Optional[int]=False   , __lowercase		:							Union[str, Any]=False   , __lowercase		:							List[str]=False   , __lowercase		:							int=0.1   , __lowercase		:							Dict=0.1   , __lowercase		:							List[str]=True   , __lowercase		:							int=[3, 5, 7, 11]   , __lowercase		:							int=[1, 2, 3, 6]   , __lowercase		:							List[str]=True   , __lowercase		:							Optional[Any]=0.4   , __lowercase		:							List[Any]=2_56   , __lowercase		:							Dict=1   , __lowercase		:							Tuple=False   , __lowercase		:							Optional[int]=2_55   , **__lowercase		:							Optional[int]   , )		->  Optional[Any]:
       super().__init__(**__lowercase )

       SCREAMING_SNAKE_CASE__       :			str													=vocab_size
       SCREAMING_SNAKE_CASE__       :			Any													=hidden_size
       SCREAMING_SNAKE_CASE__       :			Any													=num_hidden_layers
       SCREAMING_SNAKE_CASE__       :			List[Any]													=num_attention_heads
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=intermediate_size
       SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=hidden_act
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=hidden_dropout_prob
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE__       :			Tuple													=initializer_range
       SCREAMING_SNAKE_CASE__       :			Dict													=layer_norm_eps

       SCREAMING_SNAKE_CASE__       :			Dict													=image_size
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=patch_size
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=num_channels
       SCREAMING_SNAKE_CASE__       :			int													=use_mask_token
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=use_absolute_position_embeddings
       SCREAMING_SNAKE_CASE__       :			List[Any]													=use_relative_position_bias
       SCREAMING_SNAKE_CASE__       :			List[Any]													=use_shared_relative_position_bias
       SCREAMING_SNAKE_CASE__       :			Dict													=layer_scale_init_value
       SCREAMING_SNAKE_CASE__       :			List[Any]													=drop_path_rate
       SCREAMING_SNAKE_CASE__       :			int													=use_mean_pooling
       # decode head attributes (semantic segmentation)
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=out_indices
       SCREAMING_SNAKE_CASE__       :			List[str]													=pool_scales
       # auxiliary head attributes (semantic segmentation)
       SCREAMING_SNAKE_CASE__       :			List[Any]													=use_auxiliary_head
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=auxiliary_loss_weight
       SCREAMING_SNAKE_CASE__       :			str													=auxiliary_channels
       SCREAMING_SNAKE_CASE__       :			List[Any]													=auxiliary_num_convs
       SCREAMING_SNAKE_CASE__       :			Tuple													=auxiliary_concat_input
       SCREAMING_SNAKE_CASE__       :			List[str]													=semantic_loss_ignore_index






class        __SCREAMING_SNAKE_CASE (     lowerCamelCase			):
 snake_case_												=							version.parse("""1.11"""			)




 @property
 def        __magic_name__		( self		:							Optional[int] )		->  Mapping[str, Mapping[int, str]]:
       return OrderedDict(
           [
               ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
           ] )




 @property
 def        __magic_name__		( self		:							Union[str, Any] )		->  float:
       return 1e-4







'''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]