


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:      List[str] ):






            '''simple docstring'''




            __UpperCamelCase      =       10







       def 						snake_case_     (       self:      int ):






            '''simple docstring'''




            __UpperCamelCase      =       [1, 2, 3, 4]
            __UpperCamelCase      =       [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
            self.assertEqual(truncate_or_pad(SCREAMING_SNAKE_CASE_,self.block_size,0 ),SCREAMING_SNAKE_CASE_ )







       def 						snake_case_     (       self:      int ):






            '''simple docstring'''




            __UpperCamelCase      =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
            __UpperCamelCase      =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
            self.assertEqual(truncate_or_pad(SCREAMING_SNAKE_CASE_,self.block_size,0 ),SCREAMING_SNAKE_CASE_ )







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






            '''simple docstring'''




            __UpperCamelCase      =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
            __UpperCamelCase      =       [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
            self.assertEqual(truncate_or_pad(SCREAMING_SNAKE_CASE_,self.block_size,0 ),SCREAMING_SNAKE_CASE_ )







       def 						snake_case_     (       self:      Any ):






            '''simple docstring'''




            __UpperCamelCase      =       '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.'
            __UpperCamelCase,  __UpperCamelCase      =       process_story(SCREAMING_SNAKE_CASE_ )
            self.assertEqual(SCREAMING_SNAKE_CASE_,[] )







       def 						snake_case_     (       self:      List[str] ):






            '''simple docstring'''




            __UpperCamelCase      =       ''
            __UpperCamelCase,  __UpperCamelCase      =       process_story(SCREAMING_SNAKE_CASE_ )
            self.assertEqual(SCREAMING_SNAKE_CASE_,[] )
            self.assertEqual(SCREAMING_SNAKE_CASE_,[] )







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






            '''simple docstring'''




            __UpperCamelCase      =       (
                '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      =       process_story(SCREAMING_SNAKE_CASE_ )

            __UpperCamelCase      =       [
                '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(SCREAMING_SNAKE_CASE_,SCREAMING_SNAKE_CASE_ )

            __UpperCamelCase      =       ['It was the best of times.']
            self.assertEqual(SCREAMING_SNAKE_CASE_,SCREAMING_SNAKE_CASE_ )







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






            '''simple docstring'''




            __UpperCamelCase      =       torch.tensor([1, 2, 3, 4] )
            __UpperCamelCase      =       torch.tensor([1, 1, 1, 1] )
            np.testing.assert_array_equal(build_mask(SCREAMING_SNAKE_CASE_,0 ).numpy(),expected.numpy() )







       def 						snake_case_     (       self:      List[Any] ):






            '''simple docstring'''




            __UpperCamelCase      =       torch.tensor([1, 2, 3, 4, 23, 23, 23] )
            __UpperCamelCase      =       torch.tensor([1, 1, 1, 1, 0, 0, 0] )
            np.testing.assert_array_equal(build_mask(SCREAMING_SNAKE_CASE_,23 ).numpy(),expected.numpy() )







       def 						snake_case_     (       self:      int ):






            '''simple docstring'''




            __UpperCamelCase      =       torch.tensor([8, 2, 3, 4, 1, 1, 1] )
            __UpperCamelCase      =       torch.tensor([1, 1, 1, 1, 0, 0, 0] )
            np.testing.assert_array_equal(build_mask(SCREAMING_SNAKE_CASE_,1 ).numpy(),expected.numpy() )







       def 						snake_case_     (       self:      List[str] ):






            '''simple docstring'''




            __UpperCamelCase      =       101
            __UpperCamelCase      =       torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]] )
            __UpperCamelCase      =       torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]] )

            __UpperCamelCase      =       compute_token_type_ids(SCREAMING_SNAKE_CASE_,SCREAMING_SNAKE_CASE_ )
            np.testing.assert_array_equal(SCREAMING_SNAKE_CASE_,SCREAMING_SNAKE_CASE_ )




def 				a						(							snake_case__:					list					):


				'''simple docstring'''

				if len(snake_case__					) <= 1:
								return [tuple(snake_case__					)]

				lowercase_       =					[]

				def generate(snake_case__:					int						,   snake_case__:					list					):
								if k == 1:
												res.append(tuple(arr[:]					)					)
												return

								generate(k - 1						,   snake_case__					)

								for i in range(k - 1					):
												if k % 2 == 0:  # k is even
																lowercase_  ,	lowercase_       =					arr[k - 1], arr[i]
												else:  # k is odd
																lowercase_  ,	lowercase_       =					arr[k - 1], arr[0]
												generate(k - 1						,   snake_case__					)

				generate(len(snake_case__					)						,   snake_case__					)
				return res


if __name__ == "__main__":
						__a  			=					input('Enter numbers separated by a comma:\n').strip()
						__a  			=					[int(item) for item in user_input.split(',')]
						print(heaps(arr))




