





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


__lowercase       :List[str]       =  logging.get_logger(__name__)

__lowercase       :int       =  {
    "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    _a     (				lowercase__							):






							"""simple docstring"""

							snake_case_							 =						"bloom"
							snake_case_							 =						["past_key_values"]
							snake_case_							 =						{
							    "num_hidden_layers": "n_layer",
							    "num_attention_heads": "n_head",
							}

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

													SCREAMING_SNAKE_CASE__     :				List[str]   =					bos_token_id
													SCREAMING_SNAKE_CASE__     :				Any   =					eos_token_id
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					slow_but_exact

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







class    _a     (				lowercase__							):






							"""simple docstring"""

							snake_case_							 =						version.parse("1.12"							)

							def __init__(      self				:     Optional[int]							,	a				:     PretrainedConfig							,	a				:     str = "default"							,	a				:     List[PatchingSpec] = None							,	a				:     bool = False							,	)	->int:
													super().__init__(a							,	task=a							,	patching_specs=a							,	use_past=a    )
													if not getattr(self._config							,	"pad_token_id"							,	a    ):
																			# TODO: how to do that better?
																			SCREAMING_SNAKE_CASE__     :				int   =					0

							@property
							def      A_  (      self				:     Optional[Any]    )	->Mapping[str, Mapping[int, str]]:
													SCREAMING_SNAKE_CASE__     :				Tuple   =					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_(a							,	direction="inputs"							,	inverted_values_shape=a    )
																			SCREAMING_SNAKE_CASE__     :				Tuple   =					{0: "batch", 1: "past_sequence + sequence"}
													else:
																			SCREAMING_SNAKE_CASE__     :				str   =					{0: "batch", 1: "sequence"}

													return common_inputs

							@property
							def      A_  (      self				:     int    )	->int:
													return self._config.n_layer

							@property
							def      A_  (      self				:     Union[str, Any]    )	->int:
													return self._config.n_head

							@property
							def      A_  (      self				:     Optional[int]    )	->float:
													return 1E-3

							def      A_  (      self				:     Optional[Any]							,	a				:     "PreTrainedTokenizer"							,	a				:     int = -1							,	a				:     int = -1							,	a				:     bool = False							,	a				:     Optional["TensorType"] = None							,	)	->Mapping[str, Any]:
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					super(a							,	self    ).generate_dummy_inputs(
													    a							,	batch_size=a							,	seq_length=a							,	is_pair=a							,	framework=a    )

													# We need to order the input in the way they appears in the forward()
													SCREAMING_SNAKE_CASE__     :				Union[str, 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

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

													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					common_inputs["attention_mask"]
													if self.use_past:
																			SCREAMING_SNAKE_CASE__     :				Tuple   =					ordered_inputs["attention_mask"].dtype
																			SCREAMING_SNAKE_CASE__     :				Optional[int]   =					torch.cat(
																			    [ordered_inputs["attention_mask"], torch.ones(a							,	a							,	dtype=a    )]							,	dim=1    )

													return ordered_inputs






							@property
							def      A_  (      self				:     Optional[Any]    )	->int:
													return 13






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowercase       :str       =  {
    "configuration_upernet": ["UperNetConfig"],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowercase       :Union[str, Any]       =  [
				    "UperNetForSemanticSegmentation",
				    "UperNetPreTrainedModel",
				]


if TYPE_CHECKING:
				from .configuration_upernet import UperNetConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_upernet import UperNetForSemanticSegmentation, UperNetPreTrainedModel


else:
				import sys

				__lowercase       :str       =  _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)