


'''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 				UpperCAmelCase			(			unittest.TestCase						):


 def        __SCREAMING_SNAKE_CASE					(      self							:	int ):
    UpperCAmelCase__	:Tuple      =      1_0


 def        __SCREAMING_SNAKE_CASE					(      self							:	int ):
    UpperCAmelCase__	:Optional[Any]      =      [1, 2, 3, 4]
    UpperCAmelCase__	:str      =      [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
    self.assertEqual(truncate_or_pad(__lowerCamelCase			,       self.block_size			,       0 )			,       __lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[Any] ):
    UpperCAmelCase__	:Union[str, Any]      =      [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0]
    UpperCAmelCase__	:Optional[Any]      =      [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0]
    self.assertEqual(truncate_or_pad(__lowerCamelCase			,       self.block_size			,       0 )			,       __lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	str ):
    UpperCAmelCase__	:List[str]      =      [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0, 1_1, 1_2, 1_3]
    UpperCAmelCase__	:Optional[int]      =      [1, 2, 3, 4, 5, 6, 7, 8, 9, 1_0]
    self.assertEqual(truncate_or_pad(__lowerCamelCase			,       self.block_size			,       0 )			,       __lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Union[str, Any] ):
    UpperCAmelCase__	: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.'''
    UpperCAmelCase__   ,						UpperCAmelCase__	:Any      =      process_story(__lowerCamelCase )
    self.assertEqual(__lowerCamelCase			,       [] )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Union[str, Any] ):
    UpperCAmelCase__	:int      =      ''''''
    UpperCAmelCase__   ,						UpperCAmelCase__	:List[Any]      =      process_story(__lowerCamelCase )
    self.assertEqual(__lowerCamelCase			,       [] )
    self.assertEqual(__lowerCamelCase			,       [] )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[int] ):
    UpperCAmelCase__	:Any      =      (
        '''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'''
    )
    UpperCAmelCase__   ,						UpperCAmelCase__	:Optional[int]      =      process_story(__lowerCamelCase )

    UpperCAmelCase__	:Union[str, Any]      =      [
        '''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 )

    UpperCAmelCase__	:Union[str, Any]      =      ['''It was the best of times.''']
    self.assertEqual(__lowerCamelCase			,       __lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[Any] ):
    UpperCAmelCase__	:Dict      =      torch.tensor([1, 2, 3, 4] )
    UpperCAmelCase__	:int      =      torch.tensor([1, 1, 1, 1] )
    np.testing.assert_array_equal(build_mask(__lowerCamelCase			,       0 ).numpy()			,       expected.numpy() )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[Any] ):
    UpperCAmelCase__	:List[Any]      =      torch.tensor([1, 2, 3, 4, 2_3, 2_3, 2_3] )
    UpperCAmelCase__	:str      =      torch.tensor([1, 1, 1, 1, 0, 0, 0] )
    np.testing.assert_array_equal(build_mask(__lowerCamelCase			,       2_3 ).numpy()			,       expected.numpy() )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Dict ):
    UpperCAmelCase__	:Optional[Any]      =      torch.tensor([8, 2, 3, 4, 1, 1, 1] )
    UpperCAmelCase__	:Any      =      torch.tensor([1, 1, 1, 1, 0, 0, 0] )
    np.testing.assert_array_equal(build_mask(__lowerCamelCase			,       1 ).numpy()			,       expected.numpy() )





 def        __SCREAMING_SNAKE_CASE					(      self							:	List[Any] ):
    UpperCAmelCase__	:int      =      1_0_1
    UpperCAmelCase__	:Optional[Any]      =      torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 1_0_1, 5, 6], [1, 1_0_1, 3, 4, 1_0_1, 6]] )
    UpperCAmelCase__	:int      =      torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]] )

    UpperCAmelCase__	:Any      =      compute_token_type_ids(__lowerCamelCase			,       __lowerCamelCase )
    np.testing.assert_array_equal(__lowerCamelCase			,       __lowerCamelCase )







'''simple docstring'''





from ..utils import DummyObject, requires_backends




class 				UpperCAmelCase			(			metaclass=_snake_case						):
 UpperCAmelCase				=					["speech"]


 def __init__(      self							:	List[Any]			,       *__lowerCamelCase							:	List[Any]			,       **__lowerCamelCase							:	List[str] ):
    requires_backends(self			,       ['''speech'''] )




class 				UpperCAmelCase			(			metaclass=_snake_case						):
 UpperCAmelCase				=					["speech"]


 def __init__(      self							:	int			,       *__lowerCamelCase							:	List[Any]			,       **__lowerCamelCase							:	List[str] ):
    requires_backends(self			,       ['''speech'''] )



