

'''simple docstring'''






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

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


lowerCAmelCase__      		=			logging.get_logger(__name__)


lowerCAmelCase__      		=			{
    '''Salesforce/codegen-350M-nl''': '''https://huggingface.co/Salesforce/codegen-350M-nl/resolve/main/config.json''',
    '''Salesforce/codegen-350M-multi''': '''https://huggingface.co/Salesforce/codegen-350M-multi/resolve/main/config.json''',
    '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/config.json''',
    '''Salesforce/codegen-2B-nl''': '''https://huggingface.co/Salesforce/codegen-2B-nl/resolve/main/config.json''',
    '''Salesforce/codegen-2B-multi''': '''https://huggingface.co/Salesforce/codegen-2B-multi/resolve/main/config.json''',
    '''Salesforce/codegen-2B-mono''': '''https://huggingface.co/Salesforce/codegen-2B-mono/resolve/main/config.json''',
    '''Salesforce/codegen-6B-nl''': '''https://huggingface.co/Salesforce/codegen-6B-nl/resolve/main/config.json''',
    '''Salesforce/codegen-6B-multi''': '''https://huggingface.co/Salesforce/codegen-6B-multi/resolve/main/config.json''',
    '''Salesforce/codegen-6B-mono''': '''https://huggingface.co/Salesforce/codegen-6B-mono/resolve/main/config.json''',
    '''Salesforce/codegen-16B-nl''': '''https://huggingface.co/Salesforce/codegen-16B-nl/resolve/main/config.json''',
    '''Salesforce/codegen-16B-multi''': '''https://huggingface.co/Salesforce/codegen-16B-multi/resolve/main/config.json''',
    '''Salesforce/codegen-16B-mono''': '''https://huggingface.co/Salesforce/codegen-16B-mono/resolve/main/config.json''',
}






class     lowercase_			(lowerCamelCase__   ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE					:						Optional[int]           =    'codegen'
  SCREAMING_SNAKE_CASE					:						Any           =    {
      'max_position_embeddings': 'n_positions',
      'hidden_size': 'n_embd',
      'num_attention_heads': 'n_head',
      'num_hidden_layers': 'n_layer',
  }






  def __init__(   self     :  List[Any]      ,lowercase__     :  Optional[int]=5_0_4_0_0      ,lowercase__     :  List[Any]=2_0_4_8      ,lowercase__     :  Tuple=2_0_4_8      ,lowercase__     :  Optional[Any]=4_0_9_6      ,lowercase__     :  List[str]=2_8      ,lowercase__     :  int=1_6      ,lowercase__     :  Union[str, Any]=6_4      ,lowercase__     :  Dict=None      ,lowercase__     :  Optional[int]="gelu_new"      ,lowercase__     :  Union[str, Any]=0.0      ,lowercase__     :  str=0.0      ,lowercase__     :  Union[str, Any]=0.0      ,lowercase__     :  Any=1e-5      ,lowercase__     :  Optional[int]=0.0_2      ,lowercase__     :  Optional[int]=True      ,lowercase__     :  int=5_0_2_5_6      ,lowercase__     :  Tuple=5_0_2_5_6      ,lowercase__     :  List[str]=False      ,**lowercase__     :  int      ,):
   __lowercase													=				vocab_size
   __lowercase													=				n_ctx
   __lowercase													=				n_positions
   __lowercase													=				n_embd
   __lowercase													=				n_layer
   __lowercase													=				n_head
   __lowercase													=				n_inner
   __lowercase													=				rotary_dim
   __lowercase													=				activation_function
   __lowercase													=				resid_pdrop
   __lowercase													=				embd_pdrop
   __lowercase													=				attn_pdrop
   __lowercase													=				layer_norm_epsilon
   __lowercase													=				initializer_range
   __lowercase													=				use_cache

   __lowercase													=				bos_token_id
   __lowercase													=				eos_token_id

   super().__init__(
       bos_token_id=lowercase__      ,eos_token_id=lowercase__      ,tie_word_embeddings=lowercase__      ,**lowercase__    )






class     lowercase_			(lowerCamelCase__   ):




  """simple docstring"""




  def __init__(   self     :  List[Any]      ,lowercase__     :  PretrainedConfig      ,lowercase__     :  str = "default"      ,lowercase__     :  List[PatchingSpec] = None      ,lowercase__     :  bool = False      ,):
   super().__init__(lowercase__      ,task=lowercase__      ,patching_specs=lowercase__      ,use_past=lowercase__    )
   if not getattr(self._config      ,'''pad_token_id'''      ,lowercase__    ):
    # TODO: how to do that better?
    __lowercase													=				0






  @property
  def       SCREAMING_SNAKE_CASE   (   self     :  List[Any]    ):
   __lowercase													=				OrderedDict({'''input_ids''': {0: '''batch''', 1: '''sequence'''}}    )
   if self.use_past:
    self.fill_with_past_key_values_(lowercase__      ,direction='''inputs'''    )
    __lowercase													=				{0: '''batch''', 1: '''past_sequence + sequence'''}
   else:
    __lowercase													=				{0: '''batch''', 1: '''sequence'''}

   return common_inputs






  @property
  def       SCREAMING_SNAKE_CASE   (   self     :  Tuple    ):
   return self._config.n_layer






  @property
  def       SCREAMING_SNAKE_CASE   (   self     :  Union[str, Any]    ):
   return self._config.n_head






  def       SCREAMING_SNAKE_CASE   (   self     :  Any      ,lowercase__     :  PreTrainedTokenizer      ,lowercase__     :  int = -1      ,lowercase__     :  int = -1      ,lowercase__     :  bool = False      ,lowercase__     :  Optional[TensorType] = None      ,):
   __lowercase													=				super(lowercase__      ,self    ).generate_dummy_inputs(
       lowercase__      ,batch_size=lowercase__      ,seq_length=lowercase__      ,is_pair=lowercase__      ,framework=lowercase__    )

   # We need to order the input in the way they appears in the forward()
   __lowercase													=				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

     __lowercase						,			__lowercase													=				common_inputs['''input_ids'''].shape
     # Not using the same length for past_key_values
     __lowercase													=				seqlen + 2
     __lowercase													=				(
         batch,
         self.num_attention_heads,
         past_key_values_length,
         self._config.hidden_size // self.num_attention_heads,
     )
     __lowercase													=				[
         (torch.zeros(lowercase__    ), torch.zeros(lowercase__    )) for _ in range(self.num_layers    )
     ]

   __lowercase													=				common_inputs['''attention_mask''']
   if self.use_past:
    __lowercase													=				ordered_inputs['''attention_mask'''].dtype
    __lowercase													=				torch.cat(
        [ordered_inputs['''attention_mask'''], torch.ones(lowercase__      ,lowercase__      ,dtype=lowercase__    )]      ,dim=1    )

   return ordered_inputs






  @property
  def       SCREAMING_SNAKE_CASE   (   self     :  Dict    ):
   return 1_3




'''simple docstring'''






from collections.abc import Callable

import numpy as np


def 	_A  (					A__  ,       A__  ,       A__  ,       A__  ,       A__   ):






 """simple docstring"""



 __lowercase													=				int(np.ceil((x_end - xa) / step_size   )   )
 __lowercase													=				np.zeros((n + 1,)   )
 __lowercase													=				ya
 __lowercase													=				xa

 for k in range(A__   ):
  __lowercase													=				y[k] + step_size * ode_func(A__  ,       y[k]   )
  x += step_size

 return y


if __name__ == "__main__":
 import doctest

 doctest.testmod()

