





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




 def 				_snake_case (						self		)     ->				Any:
     _lowerCAmelCase						      =   10




 def 				_snake_case (						self		)     ->				Optional[int]:
     _lowerCAmelCase						      =   [1, 2, 3, 4]
     _lowerCAmelCase						      =   [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
     self.assertEqual(truncate_or_pad(_lowerCAmelCase      ,  self.block_size      ,  0		)      ,  _lowerCAmelCase		)




 def 				_snake_case (						self		)     ->				List[Any]:
     _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(_lowerCAmelCase      ,  self.block_size      ,  0		)      ,  _lowerCAmelCase		)




 def 				_snake_case (						self		)     ->				str:
     _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(_lowerCAmelCase      ,  self.block_size      ,  0		)      ,  _lowerCAmelCase		)




 def 				_snake_case (						self		)     ->				Optional[Any]:
     _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(_lowerCAmelCase		)
     self.assertEqual(_lowerCAmelCase      ,  []		)




 def 				_snake_case (						self		)     ->				Dict:
     _lowerCAmelCase						      =   ""
     _lowerCAmelCase      ,      _lowerCAmelCase						      =   process_story(_lowerCAmelCase		)
     self.assertEqual(_lowerCAmelCase      ,  []		)
     self.assertEqual(_lowerCAmelCase      ,  []		)




 def 				_snake_case (						self		)     ->				Dict:
     _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(_lowerCAmelCase		)

     _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(_lowerCAmelCase      ,  _lowerCAmelCase		)

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




 def 				_snake_case (						self		)     ->				Optional[int]:
     _lowerCAmelCase						      =   torch.tensor([1, 2, 3, 4]		)
     _lowerCAmelCase						      =   torch.tensor([1, 1, 1, 1]		)
     np.testing.assert_array_equal(build_mask(_lowerCAmelCase      ,  0		).numpy()      ,  expected.numpy()		)




 def 				_snake_case (						self		)     ->				Union[str, Any]:
     _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(_lowerCAmelCase      ,  23		).numpy()      ,  expected.numpy()		)




 def 				_snake_case (						self		)     ->				List[str]:
     _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(_lowerCAmelCase      ,  1		).numpy()      ,  expected.numpy()		)





 def 				_snake_case (						self		)     ->				Optional[Any]:
     _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(_lowerCAmelCase      ,  _lowerCAmelCase		)
     np.testing.assert_array_equal(_lowerCAmelCase      ,  _lowerCAmelCase		)









'''simple docstring'''


from __future__ import annotations


def 						__a(SCREAMING_SNAKE_CASE_	:       list     ):



    '''simple docstring'''





    if not nums:
        raise ValueError("List is empty"     )
    return sum(SCREAMING_SNAKE_CASE_     ) / len(SCREAMING_SNAKE_CASE_     )


if __name__ == "__main__":
       import doctest

       doctest.testmod()


