






'''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       __lowercase					(__lowerCamelCase    ):
	_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   :						List[str]):
			super().setup()
			UpperCamelCase__				:					List[str]					=					self.model.config
			UpperCamelCase__				:					List[str]					=					-1
			for idx, label in config.idalabel.items():
					if label.lower().startswith('entail'):
							UpperCamelCase__				:					int					=					int(UpperCAmelCase_)
			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   :						Optional[Any]  ,					UpperCAmelCase_   :						List[Any]  ,					UpperCAmelCase_   :						int):
			UpperCamelCase__				:					List[Any]					=					labels
			return self.pre_processor(
			    [text] * len(UpperCAmelCase_)  ,					[F'This example is {label}' for label in labels]  ,					return_tensors='pt'  ,					padding='max_length'  ,					)





	def      __UpperCamelCase							(      self   :						Union[str, Any]  ,					UpperCAmelCase_   :						Tuple):
			UpperCamelCase__				:					Tuple					=					outputs.logits
			UpperCamelCase__				:					Union[str, Any]					=					torch.argmax(logits[:, 2]).item()
			return self._labels[label_id]












'''simple docstring'''




from math import log

from scipy.constants import Boltzmann, physical_constants

lowerCAmelCase__          =						300  # TEMPERATURE (unit = K)







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_     ,      lowerCamelCase_     ,      )							->     float:

		if donor_conc <= 0:
				raise ValueError('Donor concentration should be positive')
		elif acceptor_conc <= 0:
				raise ValueError('Acceptor concentration should be positive')
		elif intrinsic_conc <= 0:
				raise ValueError('Intrinsic concentration should be positive')
		elif donor_conc <= intrinsic_conc:
				raise ValueError(
				    'Donor concentration should be greater than intrinsic concentration')
		elif acceptor_conc <= intrinsic_conc:
				raise ValueError(
				    'Acceptor concentration should be greater than intrinsic concentration')
		else:
				return (
				    Boltzmann
				    * T
				    * log((donor_conc * acceptor_conc) / intrinsic_conc**2)
				    / physical_constants["electron volt"][0]
				)


if __name__ == "__main__":
		import doctest

		doctest.testmod()




