
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  ):




	'''simple docstring'''


	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       10





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       [1, 2, 3, 4]
		lowercase	    =       [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
		self.assertEqual(truncate_or_pad(snake_case						,       self.block_size						,       0			)						,       snake_case			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
		lowercase	    =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
		self.assertEqual(truncate_or_pad(snake_case						,       self.block_size						,       0			)						,       snake_case			)





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





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       '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.'
		lowercase    ,   lowercase	    =       process_story(snake_case			)
		self.assertEqual(snake_case						,       []			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       ''
		lowercase    ,   lowercase	    =       process_story(snake_case			)
		self.assertEqual(snake_case						,       []			)
		self.assertEqual(snake_case						,       []			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       (
		    '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'
		)
		lowercase    ,   lowercase	    =       process_story(snake_case			)

		lowercase	    =       [
		    '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(snake_case						,       snake_case			)

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





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       torch.tensor([1, 2, 3, 4]			)
		lowercase	    =       torch.tensor([1, 1, 1, 1]			)
		np.testing.assert_array_equal(build_mask(snake_case						,       0			).numpy()						,       expected.numpy()			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       torch.tensor([1, 2, 3, 4, 23, 23, 23]			)
		lowercase	    =       torch.tensor([1, 1, 1, 1, 0, 0, 0]			)
		np.testing.assert_array_equal(build_mask(snake_case						,       23			).numpy()						,       expected.numpy()			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       torch.tensor([8, 2, 3, 4, 1, 1, 1]			)
		lowercase	    =       torch.tensor([1, 1, 1, 1, 0, 0, 0]			)
		np.testing.assert_array_equal(build_mask(snake_case						,       1			).numpy()						,       expected.numpy()			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       101
		lowercase	    =       torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]			)
		lowercase	    =       torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]			)

		lowercase	    =       compute_token_type_ids(snake_case						,       snake_case			)
		np.testing.assert_array_equal(snake_case						,       snake_case			)




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCAmelCase						:  int									=			{
    """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""],
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_UpperCAmelCase						:  str									=			[
					    """LILT_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """LiltForQuestionAnswering""",
					    """LiltForSequenceClassification""",
					    """LiltForTokenClassification""",
					    """LiltModel""",
					    """LiltPreTrainedModel""",
					]

if TYPE_CHECKING:
					from .configuration_lilt import LILT_PRETRAINED_CONFIG_ARCHIVE_MAP, LiltConfig

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_lilt import (
										    LILT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    LiltForQuestionAnswering,
										    LiltForSequenceClassification,
										    LiltForTokenClassification,
										    LiltModel,
										    LiltPreTrainedModel,
										)

else:
					import sys

					_UpperCAmelCase						:  Dict									=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




