
'''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 						a   (				unittest.TestCase    ):




				def 	__snake_case							(							self	:				str      ):
										snake_case       :     List[str] =    10




				def 	__snake_case							(							self	:				int      ):
										snake_case       :     Any =    [1, 2, 3, 4]
										snake_case       :     List[str] =    [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
										self.assertEqual(truncate_or_pad(SCREAMING_SNAKE_CASE_,    self.block_size,    0      ),    SCREAMING_SNAKE_CASE_      )




				def 	__snake_case							(							self	:				Optional[Any]      ):
										snake_case       :     Dict =    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
										snake_case       :     Dict =    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
										self.assertEqual(truncate_or_pad(SCREAMING_SNAKE_CASE_,    self.block_size,    0      ),    SCREAMING_SNAKE_CASE_      )




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




				def 	__snake_case							(							self	:				Union[str, Any]      ):
										snake_case       :     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.'''
										snake_case,					snake_case       :     Any =    process_story(SCREAMING_SNAKE_CASE_      )
										self.assertEqual(SCREAMING_SNAKE_CASE_,    []      )




				def 	__snake_case							(							self	:				Dict      ):
										snake_case       :     Dict =    ''''''
										snake_case,					snake_case       :     Optional[Any] =    process_story(SCREAMING_SNAKE_CASE_      )
										self.assertEqual(SCREAMING_SNAKE_CASE_,    []      )
										self.assertEqual(SCREAMING_SNAKE_CASE_,    []      )




				def 	__snake_case							(							self	:				int      ):
										snake_case       :     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'''
										)
										snake_case,					snake_case       :     int =    process_story(SCREAMING_SNAKE_CASE_      )

										snake_case       :     Optional[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(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )

										snake_case       :     Any =    ['''It was the best of times.''']
										self.assertEqual(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )




				def 	__snake_case							(							self	:				List[str]      ):
										snake_case       :     Dict =    torch.tensor([1, 2, 3, 4]      )
										snake_case       :     str =    torch.tensor([1, 1, 1, 1]      )
										np.testing.assert_array_equal(build_mask(SCREAMING_SNAKE_CASE_,    0      ).numpy(),    expected.numpy()      )




				def 	__snake_case							(							self	:				Any      ):
										snake_case       :     List[Any] =    torch.tensor([1, 2, 3, 4, 23, 23, 23]      )
										snake_case       :     List[str] =    torch.tensor([1, 1, 1, 1, 0, 0, 0]      )
										np.testing.assert_array_equal(build_mask(SCREAMING_SNAKE_CASE_,    23      ).numpy(),    expected.numpy()      )




				def 	__snake_case							(							self	:				Optional[int]      ):
										snake_case       :     Optional[int] =    torch.tensor([8, 2, 3, 4, 1, 1, 1]      )
										snake_case       :     Any =    torch.tensor([1, 1, 1, 1, 0, 0, 0]      )
										np.testing.assert_array_equal(build_mask(SCREAMING_SNAKE_CASE_,    1      ).numpy(),    expected.numpy()      )




				def 	__snake_case							(							self	:				Optional[int]      ):
										snake_case       :     List[Any] =    1_01
										snake_case       :     Tuple =    torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 1_01, 5, 6], [1, 1_01, 3, 4, 1_01, 6]]      )
										snake_case       :     Dict =    torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]      )

										snake_case       :     int =    compute_token_type_ids(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )
										np.testing.assert_array_equal(SCREAMING_SNAKE_CASE_,    SCREAMING_SNAKE_CASE_      )



'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase    					=   {
    "configuration_convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvBertConfig", "ConvBertOnnxConfig"],
    "tokenization_convbert": ["ConvBertTokenizer"],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCAmelCase    					=   ["ConvBertTokenizerFast"]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCAmelCase    					=   [
						    "CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "ConvBertForMaskedLM",
						    "ConvBertForMultipleChoice",
						    "ConvBertForQuestionAnswering",
						    "ConvBertForSequenceClassification",
						    "ConvBertForTokenClassification",
						    "ConvBertLayer",
						    "ConvBertModel",
						    "ConvBertPreTrainedModel",
						    "load_tf_weights_in_convbert",
						]


try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCAmelCase    					=   [
						    "TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "TFConvBertForMaskedLM",
						    "TFConvBertForMultipleChoice",
						    "TFConvBertForQuestionAnswering",
						    "TFConvBertForSequenceClassification",
						    "TFConvBertForTokenClassification",
						    "TFConvBertLayer",
						    "TFConvBertModel",
						    "TFConvBertPreTrainedModel",
						]


if TYPE_CHECKING:
						from .configuration_convbert import CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, ConvBertConfig, ConvBertOnnxConfig
						from .tokenization_convbert import ConvBertTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_convbert_fast import ConvBertTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_convbert import (
												    CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    ConvBertForMaskedLM,
												    ConvBertForMultipleChoice,
												    ConvBertForQuestionAnswering,
												    ConvBertForSequenceClassification,
												    ConvBertForTokenClassification,
												    ConvBertLayer,
												    ConvBertModel,
												    ConvBertPreTrainedModel,
												    load_tf_weights_in_convbert,
												)

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_convbert import (
												    TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFConvBertForMaskedLM,
												    TFConvBertForMultipleChoice,
												    TFConvBertForQuestionAnswering,
												    TFConvBertForSequenceClassification,
												    TFConvBertForTokenClassification,
												    TFConvBertLayer,
												    TFConvBertModel,
												    TFConvBertPreTrainedModel,
												)


else:
						import sys

						UpperCAmelCase    					=   _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)

