





from __future__ import annotations






def lowerCamelCase__       (				snake_case_      :    Any			, snake_case_      :    Union[str, Any] = None			, snake_case_      :    Union[str, Any] = None			) ->							Dict:





   if start is None:
      __snake_case							=  0

   if end is None:
      __snake_case							=  len(__a			) - 1

   if start >= end:
      return

   __snake_case							=  (start + end) // 2

   slowsort(__a			, __a			, __a			)
   slowsort(__a			, mid + 1			, __a			)

   if sequence[end] < sequence[mid]:
      __snake_case			,      __snake_case							=  sequence[mid], sequence[end]

   slowsort(__a			, __a			, end - 1			)


if __name__ == "__main__":
    from doctest import testmod

    testmod()



"""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 __lowerCAmelCase					(       unittest.TestCase   ):




			"""simple docstring"""







			def   lowerCamelCase__  (					self    :       Optional[int]						)   ->			List[str]:







								"""simple docstring"""
								A_								=    10




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







								"""simple docstring"""
								A_								=    [1, 2, 3, 4]
								A_								=    [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
								self.assertEqual(truncate_or_pad(_snake_case							, self.block_size							, 0						)							, _snake_case						)




			def   lowerCamelCase__  (					self    :       List[str]						)   ->			List[Any]:







								"""simple docstring"""
								A_								=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
								A_								=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
								self.assertEqual(truncate_or_pad(_snake_case							, self.block_size							, 0						)							, _snake_case						)




			def   lowerCamelCase__  (					self    :       str						)   ->			Dict:







								"""simple docstring"""
								A_								=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
								A_								=    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
								self.assertEqual(truncate_or_pad(_snake_case							, self.block_size							, 0						)							, _snake_case						)




			def   lowerCamelCase__  (					self    :       Dict						)   ->			Dict:







								"""simple docstring"""
								A_								=    "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."
								A_			,     A_								=    process_story(_snake_case						)
								self.assertEqual(_snake_case							, []						)




			def   lowerCamelCase__  (					self    :       str						)   ->			str:







								"""simple docstring"""
								A_								=    ""
								A_			,     A_								=    process_story(_snake_case						)
								self.assertEqual(_snake_case							, []						)
								self.assertEqual(_snake_case							, []						)




			def   lowerCamelCase__  (					self    :       Tuple						)   ->			Optional[Any]:







								"""simple docstring"""
								A_								=    (
								    "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"
								)
								A_			,     A_								=    process_story(_snake_case						)

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

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




			def   lowerCamelCase__  (					self    :       List[str]						)   ->			Optional[Any]:







								"""simple docstring"""
								A_								=    torch.tensor([1, 2, 3, 4]						)
								A_								=    torch.tensor([1, 1, 1, 1]						)
								np.testing.assert_array_equal(build_mask(_snake_case							, 0						).numpy()							, expected.numpy()						)




			def   lowerCamelCase__  (					self    :       List[Any]						)   ->			Optional[int]:







								"""simple docstring"""
								A_								=    torch.tensor([1, 2, 3, 4, 23, 23, 23]						)
								A_								=    torch.tensor([1, 1, 1, 1, 0, 0, 0]						)
								np.testing.assert_array_equal(build_mask(_snake_case							, 23						).numpy()							, expected.numpy()						)




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







								"""simple docstring"""
								A_								=    torch.tensor([8, 2, 3, 4, 1, 1, 1]						)
								A_								=    torch.tensor([1, 1, 1, 1, 0, 0, 0]						)
								np.testing.assert_array_equal(build_mask(_snake_case							, 1						).numpy()							, expected.numpy()						)






			def   lowerCamelCase__  (					self    :       int						)   ->			List[str]:







								"""simple docstring"""
								A_								=    101
								A_								=    torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]						)
								A_								=    torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]						)

								A_								=    compute_token_type_ids(_snake_case							, _snake_case						)
								np.testing.assert_array_equal(_snake_case							, _snake_case						)




