

import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad

class 			a  (	unittest.TestCase				):


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Tuple 		=    10


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Optional[int] 		=    [1, 2, 3, 4]
										_UpperCAmelCase       :		List[Any] 		=    [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
										self.assertEqual(truncate_or_pad(A_						,					self.block_size						,					0	)						,					A_	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Any 		=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
										_UpperCAmelCase       :		Union[str, Any] 		=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
										self.assertEqual(truncate_or_pad(A_						,					self.block_size						,					0	)						,					A_	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Optional[int] 		=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
										_UpperCAmelCase       :		Any 		=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
										self.assertEqual(truncate_or_pad(A_						,					self.block_size						,					0	)						,					A_	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


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


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Tuple 		=    ""
										_UpperCAmelCase       :		Optional[int] 		=    process_story(A_	)
										self.assertEqual(A_						,					[]	)
										self.assertEqual(A_						,					[]	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Tuple 		=    (
										    "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       :		str 		=    process_story(A_	)

										_UpperCAmelCase       :		int 		=    [
										    "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(A_						,					A_	)

										_UpperCAmelCase       :		int 		=    ["It was the best of times."]
										self.assertEqual(A_						,					A_	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


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


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		int 		=    torch.tensor([1, 2, 3, 4, 23, 23, 23]	)
										_UpperCAmelCase       :		int 		=    torch.tensor([1, 1, 1, 1, 0, 0, 0]	)
										np.testing.assert_array_equal(build_mask(A_						,					23	).numpy()						,					expected.numpy()	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Any 		=    torch.tensor([8, 2, 3, 4, 1, 1, 1]	)
										_UpperCAmelCase       :		Union[str, Any] 		=    torch.tensor([1, 1, 1, 1, 0, 0, 0]	)
										np.testing.assert_array_equal(build_mask(A_						,					1	).numpy()						,					expected.numpy()	)





						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		List[Any] 		=    101
										_UpperCAmelCase       :		Any 		=    torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]	)
										_UpperCAmelCase       :		str 		=    torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]	)

										_UpperCAmelCase       :		Any 		=    compute_token_type_ids(A_						,					A_	)
										np.testing.assert_array_equal(A_						,					A_	)





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


SCREAMING_SNAKE_CASE_        =      logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_        =      {
    # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert
}

class 				a  (	UpperCAmelCase				):
						_lowercase    						=			"megatron-bert"


						def __init__(       self						,					A_=29056						,					A_=1024						,					A_=24						,					A_=16						,					A_=4096						,					A_="gelu"						,					A_=0.1						,					A_=0.1						,					A_=512						,					A_=2						,					A_=0.02						,					A_=1e-12						,					A_=0						,					A_="absolute"						,					A_=True						,					**A_						,					):







										'''simple docstring'''


										super().__init__(pad_token_id=A_						,					**A_	)

										_UpperCAmelCase       :		Optional[Any] 		=    vocab_size
										_UpperCAmelCase       :		List[str] 		=    hidden_size
										_UpperCAmelCase       :		List[str] 		=    num_hidden_layers
										_UpperCAmelCase       :		Optional[Any] 		=    num_attention_heads
										_UpperCAmelCase       :		Any 		=    hidden_act
										_UpperCAmelCase       :		Optional[Any] 		=    intermediate_size
										_UpperCAmelCase       :		int 		=    hidden_dropout_prob
										_UpperCAmelCase       :		Optional[Any] 		=    attention_probs_dropout_prob
										_UpperCAmelCase       :		Any 		=    max_position_embeddings
										_UpperCAmelCase       :		str 		=    type_vocab_size
										_UpperCAmelCase       :		Optional[int] 		=    initializer_range
										_UpperCAmelCase       :		Dict 		=    layer_norm_eps
										_UpperCAmelCase       :		Tuple 		=    position_embedding_type
										_UpperCAmelCase       :		Tuple 		=    use_cache


