"""simple docstring"""





from collections import OrderedDict
from typing import List, Mapping

from packaging import version

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


lowerCAmelCase_     =	logging.get_logger(__name__)

lowerCAmelCase_     =	{
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"efficientnet"





				def __init__(      self							:							int      ,    _A							:							int = 3      ,    _A							:							int = 6_0_0      ,    _A							:							float = 2.0      ,    _A							:							float = 3.1      ,    _A							:							int = 8      ,    _A							:							List[int] = [3, 3, 5, 3, 5, 5, 3]      ,    _A							:							List[int] = [3_2, 1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2]      ,    _A							:							List[int] = [1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2, 3_2_0]      ,    _A							:							List[int] = []      ,    _A							:							List[int] = [1, 2, 2, 2, 1, 2, 1]      ,    _A							:							List[int] = [1, 2, 2, 3, 3, 4, 1]      ,    _A							:							List[int] = [1, 6, 6, 6, 6, 6, 6]      ,    _A							:							float = 0.25      ,    _A							:							str = "swish"      ,    _A							:							int = 2_5_6_0      ,    _A							:							str = "mean"      ,    _A							:							float = 0.02      ,    _A							:							float = 0.001      ,    _A							:							float = 0.99      ,    _A							:							float = 0.5      ,    _A							:							float = 0.2      ,    **_A							:							List[str]      ,    ):



											"""simple docstring"""







											super().__init__(**_A)

											_SCREAMING_SNAKE_CASE		:						List[str]			  =    num_channels
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    image_size
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    width_coefficient
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    depth_coefficient
											_SCREAMING_SNAKE_CASE		:						Dict			  =    depth_divisor
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    kernel_sizes
											_SCREAMING_SNAKE_CASE		:						Dict			  =    in_channels
											_SCREAMING_SNAKE_CASE		:						Any			  =    out_channels
											_SCREAMING_SNAKE_CASE		:						Dict			  =    depthwise_padding
											_SCREAMING_SNAKE_CASE		:						str			  =    strides
											_SCREAMING_SNAKE_CASE		:						Dict			  =    num_block_repeats
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    expand_ratios
											_SCREAMING_SNAKE_CASE		:						int			  =    squeeze_expansion_ratio
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_act
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_dim
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    pooling_type
											_SCREAMING_SNAKE_CASE		:						int			  =    initializer_range
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    batch_norm_eps
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    batch_norm_momentum
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    dropout_rate
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    drop_connect_rate
											_SCREAMING_SNAKE_CASE		:						int			  =    sum(_A) * 4




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						version.parse("1.11" )





				@property
				def 		_lowerCAmelCase		(      self							:							Optional[Any]):



											"""simple docstring"""







											return OrderedDict(
											    [
											        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
											    ])





				@property
				def 		_lowerCAmelCase		(      self							:							str):



											"""simple docstring"""







											return 1e-5



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


