






'''simple docstring'''




from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional

from packaging import version


if TYPE_CHECKING:
		from ... import PreTrainedTokenizer, TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import is_torch_available, logging


lowerCAmelCase__          =						logging.get_logger(__name__)

lowerCAmelCase__          =						{
    """bigscience/bloom""": """https://huggingface.co/bigscience/bloom/resolve/main/config.json""",
    """bigscience/bloom-560m""": """https://huggingface.co/bigscience/bloom-560m/blob/main/config.json""",
    """bigscience/bloom-1b1""": """https://huggingface.co/bigscience/bloom-1b1/blob/main/config.json""",
    """bigscience/bloom-1b7""": """https://huggingface.co/bigscience/bloom-1b7/blob/main/config.json""",
    """bigscience/bloom-3b""": """https://huggingface.co/bigscience/bloom-3b/blob/main/config.json""",
    """bigscience/bloom-7b1""": """https://huggingface.co/bigscience/bloom-7b1/blob/main/config.json""",
}







class       __lowercase					(lowercase_    ):
	_lowerCamelCase              =  '''bloom'''
	_lowerCamelCase              =  ['''past_key_values''']
	_lowerCamelCase              =  {
	    '''num_hidden_layers''': '''n_layer''',
	    '''num_attention_heads''': '''n_head''',
	}

	def __init__(      self   :						List[str]  ,					UpperCAmelCase_   :						Dict=250_880  ,					UpperCAmelCase_   :						Any=64  ,					UpperCAmelCase_   :						Union[str, Any]=2  ,					UpperCAmelCase_   :						Tuple=8  ,					UpperCAmelCase_   :						str=1e-5  ,					UpperCAmelCase_   :						str=0.02  ,					UpperCAmelCase_   :						Union[str, Any]=True  ,					UpperCAmelCase_   :						Union[str, Any]=1  ,					UpperCAmelCase_   :						Any=2  ,					UpperCAmelCase_   :						List[Any]=False  ,					UpperCAmelCase_   :						Tuple=0.0  ,					UpperCAmelCase_   :						Union[str, Any]=0.0  ,					UpperCAmelCase_   :						Union[str, Any]=1  ,					UpperCAmelCase_   :						str=False  ,					**UpperCAmelCase_   :						List[str]  ,					):
			UpperCamelCase__				:					Any					=					vocab_size
			# Backward compatibility with n_embed kwarg
			UpperCamelCase__				:					int					=					kwargs.pop('n_embed'  ,					UpperCAmelCase_)
			UpperCamelCase__				:					List[Any]					=					hidden_size if n_embed is None else n_embed
			UpperCamelCase__				:					Union[str, Any]					=					n_layer
			UpperCamelCase__				:					Tuple					=					n_head
			UpperCamelCase__				:					List[Any]					=					layer_norm_epsilon
			UpperCamelCase__				:					Any					=					initializer_range
			UpperCamelCase__				:					List[Any]					=					use_cache
			UpperCamelCase__				:					Dict					=					pretraining_tp
			UpperCamelCase__				:					Optional[Any]					=					apply_residual_connection_post_layernorm
			UpperCamelCase__				:					Dict					=					hidden_dropout
			UpperCamelCase__				:					Tuple					=					attention_dropout

			UpperCamelCase__				:					List[str]					=					bos_token_id
			UpperCamelCase__				:					Optional[Any]					=					eos_token_id
			UpperCamelCase__				:					Tuple					=					slow_but_exact

			super().__init__(bos_token_id=UpperCAmelCase_  ,					eos_token_id=UpperCAmelCase_  ,					**UpperCAmelCase_)







class       __lowercase					(lowercase_    ):
	_lowerCamelCase              =  version.parse('''1.12'''    )

	def __init__(      self   :						Optional[int]  ,					UpperCAmelCase_   :						Tuple  ,					UpperCAmelCase_   :						Tuple = "default"  ,					UpperCAmelCase_   :						Optional[int] = None  ,					UpperCAmelCase_   :						Optional[int] = False  ,					):
			super().__init__(UpperCAmelCase_  ,					task=UpperCAmelCase_  ,					patching_specs=UpperCAmelCase_  ,					use_past=UpperCAmelCase_)
			if not getattr(self._config  ,					'pad_token_id'  ,					UpperCAmelCase_):
					# TODO: how to do that better?
					UpperCamelCase__				:					Dict					=					0

	@property
	def      __UpperCamelCase							(      self   :						str):
			UpperCamelCase__				:					Any					=					OrderedDict({'input_ids': {0: 'batch', 1: 'sequence'}})
			if self.use_past:
					# BLOOM stores values on dynamic axis 2. For more details see: https://github.com/huggingface/transformers/pull/18344
					self.fill_with_past_key_values_(UpperCAmelCase_  ,					direction='inputs'  ,					inverted_values_shape=UpperCAmelCase_)
					UpperCamelCase__				:					Tuple					=					{0: 'batch', 1: 'past_sequence + sequence'}
			else:
					UpperCamelCase__				:					List[str]					=					{0: 'batch', 1: 'sequence'}

			return common_inputs

	@property
	def      __UpperCamelCase							(      self   :						Optional[Any]):
			return self._config.n_layer

	@property
	def      __UpperCamelCase							(      self   :						int):
			return self._config.n_head

	@property
	def      __UpperCamelCase							(      self   :						Optional[Any]):
			return 1e-3

	def      __UpperCamelCase							(      self   :						Union[str, Any]  ,					UpperCAmelCase_   :						List[Any]  ,					UpperCAmelCase_   :						int = -1  ,					UpperCAmelCase_   :						Dict = -1  ,					UpperCAmelCase_   :						Any = False  ,					UpperCAmelCase_   :						List[str] = None  ,					):
			UpperCamelCase__				:					Optional[int]					=					super(UpperCAmelCase_  ,					self).generate_dummy_inputs(
			    UpperCAmelCase_  ,					batch_size=UpperCAmelCase_  ,					seq_length=UpperCAmelCase_  ,					is_pair=UpperCAmelCase_  ,					framework=UpperCAmelCase_)

			# We need to order the input in the way they appears in the forward()
			UpperCamelCase__				:					Optional[Any]					=					OrderedDict({'input_ids': common_inputs['input_ids']})

			# Need to add the past_keys
			if self.use_past:
					if not is_torch_available():
							raise ValueError('Cannot generate dummy past_keys inputs without PyTorch installed.')
					else:
							import torch

							UpperCamelCase__,	UpperCamelCase__				:					Any					=					common_inputs['input_ids'].shape
							# Not using the same length for past_key_values
							UpperCamelCase__				:					List[Any]					=					seqlen + 2
							UpperCamelCase__				:					List[Any]					=					self._config.hidden_size // self.num_attention_heads
							UpperCamelCase__				:					List[Any]					=					(
							    batch * self.num_attention_heads,
							    head_dim,
							    past_key_values_length,
							)
							UpperCamelCase__				:					str					=					(
							    batch * self.num_attention_heads,
							    past_key_values_length,
							    head_dim,
							)
							UpperCamelCase__				:					List[str]					=					[
							    (torch.zeros(UpperCAmelCase_), torch.zeros(UpperCAmelCase_)) for _ in range(self.num_layers)
							]

			UpperCamelCase__				:					Union[str, Any]					=					common_inputs['attention_mask']
			if self.use_past:
					UpperCamelCase__				:					Tuple					=					ordered_inputs['attention_mask'].dtype
					UpperCamelCase__				:					Any					=					torch.cat(
					    [ordered_inputs['attention_mask'], torch.ones(UpperCAmelCase_  ,					UpperCAmelCase_  ,					dtype=UpperCAmelCase_)]  ,					dim=1)

			return ordered_inputs





	@property
	def      __UpperCamelCase							(      self   :						List[str]):
			return 13







'''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()




