




import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad
class        __snake_case  (unittest.TestCase		):



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





								'''simple docstring'''




								_lowerCAmelCase    :    Dict										=      10



				def       SCREAMING_SNAKE_CASE       (      self      :		Tuple      )  ->    List[Any]:





								'''simple docstring'''




								_lowerCAmelCase    :    Dict										=      [1, 2, 3, 4]
								_lowerCAmelCase    :    Optional[int]										=      [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
								self.assertEqual(truncate_or_pad(_UpperCAmelCase		,	self.block_size		,	0      )		,	_UpperCAmelCase      )



				def       SCREAMING_SNAKE_CASE       (      self      :		int      )  ->    Tuple:





								'''simple docstring'''




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



				def       SCREAMING_SNAKE_CASE       (      self      :		str      )  ->    Tuple:





								'''simple docstring'''




								_lowerCAmelCase    :    List[Any]										=      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
								_lowerCAmelCase    :    Dict										=      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
								self.assertEqual(truncate_or_pad(_UpperCAmelCase		,	self.block_size		,	0      )		,	_UpperCAmelCase      )



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





								'''simple docstring'''




								_lowerCAmelCase    :    Optional[int]										=      """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."""
								_lowerCAmelCase    :    int										=      process_story(_UpperCAmelCase      )
								self.assertEqual(_UpperCAmelCase		,	[]      )



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





								'''simple docstring'''




								_lowerCAmelCase    :    Optional[Any]										=      """"""
								_lowerCAmelCase    :    Union[str, Any]										=      process_story(_UpperCAmelCase      )
								self.assertEqual(_UpperCAmelCase		,	[]      )
								self.assertEqual(_UpperCAmelCase		,	[]      )



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





								'''simple docstring'''




								_lowerCAmelCase    :    List[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"""
								)
								_lowerCAmelCase    :    Any										=      process_story(_UpperCAmelCase      )

								_lowerCAmelCase    :    int										=      [
								    """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      )

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



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





								'''simple docstring'''




								_lowerCAmelCase    :    List[str]										=      torch.tensor([1, 2, 3, 4]      )
								_lowerCAmelCase    :    int										=      torch.tensor([1, 1, 1, 1]      )
								np.testing.assert_array_equal(build_mask(_UpperCAmelCase		,	0      ).numpy()		,	expected.numpy()      )



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





								'''simple docstring'''




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



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





								'''simple docstring'''




								_lowerCAmelCase    :    Optional[Any]										=      torch.tensor([8, 2, 3, 4, 1, 1, 1]      )
								_lowerCAmelCase    :    int										=      torch.tensor([1, 1, 1, 1, 0, 0, 0]      )
								np.testing.assert_array_equal(build_mask(_UpperCAmelCase		,	1      ).numpy()		,	expected.numpy()      )



				def       SCREAMING_SNAKE_CASE       (      self      :		Dict      )  ->    Tuple:





								'''simple docstring'''




								_lowerCAmelCase    :    Dict										=      101
								_lowerCAmelCase    :    Union[str, Any]										=      torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]      )
								_lowerCAmelCase    :    Union[str, Any]										=      torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]      )

								_lowerCAmelCase    :    str										=      compute_token_type_ids(_UpperCAmelCase		,	_UpperCAmelCase      )
								np.testing.assert_array_equal(_UpperCAmelCase		,	_UpperCAmelCase      )







from math import loga




def 							_UpperCAmelCase  (UpperCamelCase_ : int       ):
				'''simple docstring'''
				if a < 0:
								raise ValueError("""Input value must be a positive integer"""       )
				elif isinstance(UpperCamelCase_      ,    UpperCamelCase_       ):
								raise TypeError("""Input value must be a 'int' type"""       )
				return 0 if (a == 0) else int(loga(a & -a       )       )


if __name__ == "__main__":
	import doctest

	doctest.testmod()

