


"""simple docstring"""







from typing import Optional, Union

import torch
from torch import nn

from ...configuration_utils import ConfigMixin, register_to_config
from ...models.modeling_utils import ModelMixin




class 			UpperCamelCase_     (			A__      ,  A__):

	"""simple docstring"""





	@register_to_config
	def __init__(			self      :    Optional[int]      ,      UpperCAmelCase__      :    int = 7_6_8      ,      )	->     Any:
						super().__init__()

						__SCREAMING_SNAKE_CASE						       =    nn.Parameter(torch.zeros(1      ,      __snake_case       )       )
						__SCREAMING_SNAKE_CASE						       =    nn.Parameter(torch.ones(1      ,      __snake_case       )       )




	def   UpperCAmelCase_				(			self      :    str      ,      UpperCAmelCase__      :    Optional[Union[str, torch.device]] = None      ,      UpperCAmelCase__      :    Optional[torch.dtype] = None      ,      )	->     Any:
						__SCREAMING_SNAKE_CASE						       =    nn.Parameter(self.mean.to(__snake_case       ).to(__snake_case       )       )
						__SCREAMING_SNAKE_CASE						       =    nn.Parameter(self.std.to(__snake_case       ).to(__snake_case       )       )
						return self




	def   UpperCAmelCase_				(			self      :    Union[str, Any]      ,      UpperCAmelCase__      :    Dict       )	->     Tuple:
						__SCREAMING_SNAKE_CASE						       =    (embeds - self.mean) * 1.0 / self.std
						return embeds




	def   UpperCAmelCase_				(			self      :    List[Any]      ,      UpperCAmelCase__      :    Union[str, Any]       )	->     Any:
						__SCREAMING_SNAKE_CASE						       =    (embeds * self.std) + self.mean
						return embeds




"""simple docstring"""







from ...configuration_utils import PretrainedConfig
from ...utils import logging


a__    :							int            =					logging.get_logger(__name__)

a__    :							Tuple            =					{'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''}




class 			UpperCamelCase_     (			UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  Dict    =      "ctrl"
	snake_case__    :  int    =      ["past_key_values"]
	snake_case__    :  Tuple    =      {
	    "max_position_embeddings": "n_positions",
	    "hidden_size": "n_embd",
	    "num_attention_heads": "n_head",
	    "num_hidden_layers": "n_layer",
	}




	def __init__(			self      :    List[Any]      ,      UpperCAmelCase__      :    Any=2_4_6_5_3_4      ,      UpperCAmelCase__      :    List[Any]=2_5_6      ,      UpperCAmelCase__      :    Optional[int]=1_2_8_0      ,      UpperCAmelCase__      :    Optional[Any]=8_1_9_2      ,      UpperCAmelCase__      :    int=4_8      ,      UpperCAmelCase__      :    Optional[int]=1_6      ,      UpperCAmelCase__      :    Tuple=0.1      ,      UpperCAmelCase__      :    Optional[Any]=0.1      ,      UpperCAmelCase__      :    Any=1E-6      ,      UpperCAmelCase__      :    List[str]=0.02      ,      UpperCAmelCase__      :    Union[str, Any]=True      ,      **UpperCAmelCase__      :    Tuple      ,      )	->     str:
						__SCREAMING_SNAKE_CASE						       =    vocab_size
						__SCREAMING_SNAKE_CASE						       =    n_positions
						__SCREAMING_SNAKE_CASE						       =    n_embd
						__SCREAMING_SNAKE_CASE						       =    n_layer
						__SCREAMING_SNAKE_CASE						       =    n_head
						__SCREAMING_SNAKE_CASE						       =    dff
						__SCREAMING_SNAKE_CASE						       =    resid_pdrop
						__SCREAMING_SNAKE_CASE						       =    embd_pdrop
						__SCREAMING_SNAKE_CASE						       =    layer_norm_epsilon
						__SCREAMING_SNAKE_CASE						       =    initializer_range

						__SCREAMING_SNAKE_CASE						       =    use_cache

						super().__init__(**UpperCAmelCase__       )
