






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

	def 		UpperCAmelCase  (							self       )->					Tuple:







							'''simple docstring'''





							lowerCAmelCase__       =						10

	def 		UpperCAmelCase  (							self       )->					Optional[Any]:







							'''simple docstring'''





							lowerCAmelCase__       =						[1, 2, 3, 4]
							lowerCAmelCase__       =						[1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
							self.assertEqual(truncate_or_pad(__UpperCAmelCase		,    self.block_size		,    0       )		,    __UpperCAmelCase       )

	def 		UpperCAmelCase  (							self       )->					Union[str, Any]:







							'''simple docstring'''





							lowerCAmelCase__       =						[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
							lowerCAmelCase__       =						[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
							self.assertEqual(truncate_or_pad(__UpperCAmelCase		,    self.block_size		,    0       )		,    __UpperCAmelCase       )

	def 		UpperCAmelCase  (							self       )->					str:







							'''simple docstring'''





							lowerCAmelCase__       =						[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
							lowerCAmelCase__       =						[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
							self.assertEqual(truncate_or_pad(__UpperCAmelCase		,    self.block_size		,    0       )		,    __UpperCAmelCase       )

	def 		UpperCAmelCase  (							self       )->					Tuple:







							'''simple docstring'''





							lowerCAmelCase__       =						"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."
							lowerCAmelCase__      ,							lowerCAmelCase__       =						process_story(__UpperCAmelCase       )
							self.assertEqual(__UpperCAmelCase		,    []       )

	def 		UpperCAmelCase  (							self       )->					Optional[int]:







							'''simple docstring'''





							lowerCAmelCase__       =						""
							lowerCAmelCase__      ,							lowerCAmelCase__       =						process_story(__UpperCAmelCase       )
							self.assertEqual(__UpperCAmelCase		,    []       )
							self.assertEqual(__UpperCAmelCase		,    []       )

	def 		UpperCAmelCase  (							self       )->					Union[str, Any]:







							'''simple docstring'''





							lowerCAmelCase__       =						(
							    "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"
							)
							lowerCAmelCase__      ,							lowerCAmelCase__       =						process_story(__UpperCAmelCase       )

							lowerCAmelCase__       =						[
							    "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(__UpperCAmelCase		,    __UpperCAmelCase       )

							lowerCAmelCase__       =						["It was the best of times."]
							self.assertEqual(__UpperCAmelCase		,    __UpperCAmelCase       )

	def 		UpperCAmelCase  (							self       )->					Any:







							'''simple docstring'''





							lowerCAmelCase__       =						torch.tensor([1, 2, 3, 4]       )
							lowerCAmelCase__       =						torch.tensor([1, 1, 1, 1]       )
							np.testing.assert_array_equal(build_mask(__UpperCAmelCase		,    0       ).numpy()		,    expected.numpy()       )

	def 		UpperCAmelCase  (							self       )->					Union[str, Any]:







							'''simple docstring'''





							lowerCAmelCase__       =						torch.tensor([1, 2, 3, 4, 23, 23, 23]       )
							lowerCAmelCase__       =						torch.tensor([1, 1, 1, 1, 0, 0, 0]       )
							np.testing.assert_array_equal(build_mask(__UpperCAmelCase		,    23       ).numpy()		,    expected.numpy()       )

	def 		UpperCAmelCase  (							self       )->					Tuple:







							'''simple docstring'''





							lowerCAmelCase__       =						torch.tensor([8, 2, 3, 4, 1, 1, 1]       )
							lowerCAmelCase__       =						torch.tensor([1, 1, 1, 1, 0, 0, 0]       )
							np.testing.assert_array_equal(build_mask(__UpperCAmelCase		,    1       ).numpy()		,    expected.numpy()       )


	def 		UpperCAmelCase  (							self       )->					Optional[int]:







							'''simple docstring'''





							lowerCAmelCase__       =						101
							lowerCAmelCase__       =						torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]       )
							lowerCAmelCase__       =						torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]       )

							lowerCAmelCase__       =						compute_token_type_ids(__UpperCAmelCase		,    __UpperCAmelCase       )
							np.testing.assert_array_equal(__UpperCAmelCase		,    __UpperCAmelCase       )














from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


a_							=    {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	a_							=    [
	    '''SEW_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''SEWForCTC''',
	    '''SEWForSequenceClassification''',
	    '''SEWModel''',
	    '''SEWPreTrainedModel''',
	]

if TYPE_CHECKING:
	from .configuration_sew import SEW_PRETRAINED_CONFIG_ARCHIVE_MAP, SEWConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_sew import (
		    SEW_PRETRAINED_MODEL_ARCHIVE_LIST,
		    SEWForCTC,
		    SEWForSequenceClassification,
		    SEWModel,
		    SEWPreTrainedModel,
		)


else:
	import sys

	a_							=    _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






