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


lowerCamelCase__     :		Dict        = logging.get_logger(__name__)

lowerCamelCase__     :		Tuple        = {
    """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""",
}



class    _snake_case (						lowerCAmelCase__				):
 __lowerCAmelCase	:  Tuple	   =      'gpt_bigcode'
 __lowerCAmelCase	:  str	   =      ['past_key_values']
 __lowerCAmelCase	:  Optional[int]	   =      {
     'hidden_size': 'n_embd',
     'max_position_embeddings': 'n_positions',
     'num_attention_heads': 'n_head',
     'num_hidden_layers': 'n_layer',
 }


 def __init__(       self       ,	SCREAMING_SNAKE_CASE_=5_02_57       ,	SCREAMING_SNAKE_CASE_=10_24       ,	SCREAMING_SNAKE_CASE_=7_68       ,	SCREAMING_SNAKE_CASE_=12       ,	SCREAMING_SNAKE_CASE_=12       ,	SCREAMING_SNAKE_CASE_=None       ,	SCREAMING_SNAKE_CASE_="gelu_pytorch_tanh"       ,	SCREAMING_SNAKE_CASE_=0.1       ,	SCREAMING_SNAKE_CASE_=0.1       ,	SCREAMING_SNAKE_CASE_=0.1       ,	SCREAMING_SNAKE_CASE_=1E-5       ,	SCREAMING_SNAKE_CASE_=0.0_2       ,	SCREAMING_SNAKE_CASE_=True       ,	SCREAMING_SNAKE_CASE_=True       ,	SCREAMING_SNAKE_CASE_=5_02_56       ,	SCREAMING_SNAKE_CASE_=5_02_56       ,	SCREAMING_SNAKE_CASE_=True       ,	SCREAMING_SNAKE_CASE_=True       ,	SCREAMING_SNAKE_CASE_=True       ,	**SCREAMING_SNAKE_CASE_       ,	):


   '''simple docstring'''




   lowercase__	: Dict     		=   vocab_size
   lowercase__	: Union[str, Any]     		=   n_positions
   lowercase__	: List[str]     		=   n_embd
   lowercase__	: Dict     		=   n_layer
   lowercase__	: str     		=   n_head
   lowercase__	: Any     		=   n_inner
   lowercase__	: Optional[int]     		=   activation_function
   lowercase__	: str     		=   resid_pdrop
   lowercase__	: Optional[int]     		=   embd_pdrop
   lowercase__	: str     		=   attn_pdrop
   lowercase__	: Optional[int]     		=   layer_norm_epsilon
   lowercase__	: Union[str, Any]     		=   initializer_range
   lowercase__	: Optional[Any]     		=   scale_attn_weights
   lowercase__	: str     		=   use_cache
   lowercase__	: Dict     		=   attention_softmax_in_fpaa
   lowercase__	: Union[str, Any]     		=   scale_attention_softmax_in_fpaa
   lowercase__	: Union[str, Any]     		=   multi_query

   lowercase__	: Tuple     		=   bos_token_id
   lowercase__	: Dict     		=   eos_token_id

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









"""simple docstring"""
import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad

class       lowerCamelCase	(       unittest.TestCase   ):


  '''simple docstring'''







  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							List[str]							=    10



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							List[str]							=    [1, 2, 3, 4]
        UpperCAmelCase__			:							Tuple							=    [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
        self.assertEqual(truncate_or_pad(_lowerCamelCase							,       self.block_size							,       0	)							,       _lowerCamelCase	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							Optional[int]							=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        UpperCAmelCase__			:							Tuple							=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        self.assertEqual(truncate_or_pad(_lowerCamelCase							,       self.block_size							,       0	)							,       _lowerCamelCase	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							Tuple							=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
        UpperCAmelCase__			:							Dict							=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        self.assertEqual(truncate_or_pad(_lowerCamelCase							,       self.block_size							,       0	)							,       _lowerCamelCase	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							Any							=    """It was the year of Our Lord one thousand seven hundred and
        seventy-five.\n\nSpiritual revelations were conceded to England at that
        favoured period, as at this."""
        UpperCAmelCase__					,		UpperCAmelCase__			:							Any							=    process_story(_lowerCamelCase	)
        self.assertEqual(_lowerCamelCase							,       []	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							str							=    """"""
        UpperCAmelCase__					,		UpperCAmelCase__			:							List[Any]							=    process_story(_lowerCamelCase	)
        self.assertEqual(_lowerCamelCase							,       []	)
        self.assertEqual(_lowerCamelCase							,       []	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							Optional[Any]							=    (
            """It was the year of Our Lord one thousand seven hundred and """
            """seventy-five\n\nSpiritual revelations were conceded to England """
            """at that favoured period, as at this.\n@highlight\n\nIt was the best of times"""
        )
        UpperCAmelCase__					,		UpperCAmelCase__			:							Optional[Any]							=    process_story(_lowerCamelCase	)

        UpperCAmelCase__			:							List[Any]							=    [
            """It was the year of Our Lord one thousand seven hundred and seventy-five.""",
            """Spiritual revelations were conceded to England at that favoured period, as at this.""",
        ]
        self.assertEqual(_lowerCamelCase							,       _lowerCamelCase	)

        UpperCAmelCase__			:							List[Any]							=    ["""It was the best of times."""]
        self.assertEqual(_lowerCamelCase							,       _lowerCamelCase	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							str							=    torch.tensor([1, 2, 3, 4]	)
        UpperCAmelCase__			:							str							=    torch.tensor([1, 1, 1, 1]	)
        np.testing.assert_array_equal(build_mask(_lowerCamelCase							,       0	).numpy()							,       expected.numpy()	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							List[str]							=    torch.tensor([1, 2, 3, 4, 23, 23, 23]	)
        UpperCAmelCase__			:							Union[str, Any]							=    torch.tensor([1, 1, 1, 1, 0, 0, 0]	)
        np.testing.assert_array_equal(build_mask(_lowerCamelCase							,       23	).numpy()							,       expected.numpy()	)



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							Optional[Any]							=    torch.tensor([8, 2, 3, 4, 1, 1, 1]	)
        UpperCAmelCase__			:							Any							=    torch.tensor([1, 1, 1, 1, 0, 0, 0]	)
        np.testing.assert_array_equal(build_mask(_lowerCamelCase							,       1	).numpy()							,       expected.numpy()	)




  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							Any							=    101
        UpperCAmelCase__			:							Dict							=    torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]	)
        UpperCAmelCase__			:							Optional[Any]							=    torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]	)

        UpperCAmelCase__			:							int							=    compute_token_type_ids(_lowerCamelCase							,       _lowerCamelCase	)
        np.testing.assert_array_equal(_lowerCamelCase							,       _lowerCamelCase	)

