






import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad



class 				__UpperCAmelCase		(unittest.TestCase   ):







			def 							UpperCamelCase				(     self:  List[Any]					):







									'''simple docstring'''




									_SCREAMING_SNAKE_CASE     				=  10







			def 							UpperCamelCase				(     self:  List[Any]					):







									'''simple docstring'''




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







			def 							UpperCamelCase				(     self:  Optional[int]					):







									'''simple docstring'''




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







			def 							UpperCamelCase				(     self:  Dict					):







									'''simple docstring'''




									_SCREAMING_SNAKE_CASE     				=  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
									_SCREAMING_SNAKE_CASE     				=  [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'''




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







			def 							UpperCamelCase				(     self:  Optional[Any]					):







									'''simple docstring'''




									_SCREAMING_SNAKE_CASE     				=  """"""
									_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE     				=  process_story(UpperCAmelCase_					)
									self.assertEqual(UpperCAmelCase_				,     []					)
									self.assertEqual(UpperCAmelCase_				,     []					)







			def 							UpperCamelCase				(     self:  List[Any]					):







									'''simple docstring'''




									_SCREAMING_SNAKE_CASE     				=  (
									    """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"""
									)
									_SCREAMING_SNAKE_CASE				,					_SCREAMING_SNAKE_CASE     				=  process_story(UpperCAmelCase_					)

									_SCREAMING_SNAKE_CASE     				=  [
									    """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_					)

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







			def 							UpperCamelCase				(     self:  Dict					):







									'''simple docstring'''




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







			def 							UpperCamelCase				(     self:  Any					):







									'''simple docstring'''




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







			def 							UpperCamelCase				(     self:  Union[str, Any]					):







									'''simple docstring'''




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







			def 							UpperCamelCase				(     self:  List[Any]					):







									'''simple docstring'''




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

									_SCREAMING_SNAKE_CASE     				=  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


UpperCamelCase			    =     {'''configuration_mmbt''': ['''MMBTConfig''']}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCamelCase			    =     ['''MMBTForClassification''', '''MMBTModel''', '''ModalEmbeddings''']


if TYPE_CHECKING:
		from .configuration_mmbt import MMBTConfig

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_mmbt import MMBTForClassification, MMBTModel, ModalEmbeddings

else:
		import sys

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

