





'''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 							lowercase__				(			self		: List[Any]						):





        """simple docstring"""




        lowercase_      :Union[str, Any]         =			10





     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        lowercase_      :int         =			[1, 2, 3, 4]
        lowercase_      :Union[str, Any]         =			[1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
        self.assertEqual(truncate_or_pad(lowercase     ,				self.block_size     ,				0						)     ,				lowercase						)





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





        """simple docstring"""




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





     def 							lowercase__				(			self		: Any						):





        """simple docstring"""




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





     def 							lowercase__				(			self		: str						):





        """simple docstring"""




        lowercase_      :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."
        lowercase_      :Union[str, Any]         =			process_story(lowercase						)
        self.assertEqual(lowercase     ,				[]						)





     def 							lowercase__				(			self		: Any						):





        """simple docstring"""




        lowercase_      :Tuple         =			""
        lowercase_      :Any         =			process_story(lowercase						)
        self.assertEqual(lowercase     ,				[]						)
        self.assertEqual(lowercase     ,				[]						)





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





        """simple docstring"""




        lowercase_      :str         =			(
            "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_      :str         =			process_story(lowercase						)

        lowercase_      :List[str]         =			[
            "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(lowercase     ,				lowercase						)

        lowercase_      :Union[str, Any]         =			["It was the best of times."]
        self.assertEqual(lowercase     ,				lowercase						)





     def 							lowercase__				(			self		: List[Any]						):





        """simple docstring"""




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





     def 							lowercase__				(			self		: str						):





        """simple docstring"""




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





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





        """simple docstring"""




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







     def 							lowercase__				(			self		: Dict						):





        """simple docstring"""




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

        lowercase_      :int         =			compute_token_type_ids(lowercase     ,				lowercase						)
        np.testing.assert_array_equal(lowercase     ,				lowercase						)









'''simple docstring'''


def 							UpperCAmelCase_  (						__lowerCamelCase : str     ,__lowerCamelCase : str			):
   lowercase_      :Optional[Any]         =			len(__lowerCamelCase			)
   lowercase_      :List[Any]         =			[]
   for i in range(len(__lowerCamelCase			) - pat_len + 1			):
      lowercase_      :Dict         =			True
      for j in range(__lowerCamelCase			):
         if s[i + j] != pattern[j]:
            lowercase_      :int         =			False
            break
      if match_found:
         position.append(__lowerCamelCase			)
   return position


if __name__ == "__main__":
 assert naive_pattern_search('''ABCDEFG''', '''DE''') == [3]
 print(naive_pattern_search('''ABAAABCDBBABCDDEBCABC''', '''ABC'''))


