



import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad

class 					_A (			unittest.TestCase					):



       def 	_lowerCamelCase    (	self							:  Optional[int]):


           '''simple docstring'''

           __a		 =       10



       def 	_lowerCamelCase    (	self							:  Dict):


           '''simple docstring'''

           __a		 =       [1, 2, 3, 4]
           __a		 =       [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 	_lowerCamelCase    (	self							:  int):


           '''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(__SCREAMING_SNAKE_CASE  ,	self.block_size  ,	0)  ,	__SCREAMING_SNAKE_CASE)



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


           '''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(__SCREAMING_SNAKE_CASE  ,	self.block_size  ,	0)  ,	__SCREAMING_SNAKE_CASE)



       def 	_lowerCamelCase    (	self							:  int):


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



       def 	_lowerCamelCase    (	self							:  int):


           '''simple docstring'''

           __a		 =       ''''''
           __a ,     __a		 =       process_story(__SCREAMING_SNAKE_CASE)
           self.assertEqual(__SCREAMING_SNAKE_CASE  ,	[])
           self.assertEqual(__SCREAMING_SNAKE_CASE  ,	[])



       def 	_lowerCamelCase    (	self							:  List[str]):


           '''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(__SCREAMING_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(__SCREAMING_SNAKE_CASE  ,	__SCREAMING_SNAKE_CASE)

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



       def 	_lowerCamelCase    (	self							:  int):


           '''simple docstring'''

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



       def 	_lowerCamelCase    (	self							:  Dict):


           '''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(__SCREAMING_SNAKE_CASE  ,	23).numpy()  ,	expected.numpy())



       def 	_lowerCamelCase    (	self							:  Dict):


           '''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(__SCREAMING_SNAKE_CASE  ,	1).numpy()  ,	expected.numpy())





       def 	_lowerCamelCase    (	self							:  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(__SCREAMING_SNAKE_CASE  ,	__SCREAMING_SNAKE_CASE)
           np.testing.assert_array_equal(__SCREAMING_SNAKE_CASE  ,	__SCREAMING_SNAKE_CASE)










from __future__ import annotations





def   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase       ):
    print(f'Vertex\tShortest Distance from vertex {src}'       )
    for i, d in enumerate(_UpperCAmelCase       ):
        print(f'{i}\t\t{d}'       )





def   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase     ,				_UpperCAmelCase       ):
    for j in range(_UpperCAmelCase       ):
        __a ,     __a ,     __a		 =       (graph[j][k] for k in ['''src''', '''dst''', '''weight'''])
        if distance[u] != float('''inf'''       ) and distance[u] + w < distance[v]:
            return True
    return False





def   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase     ,				_UpperCAmelCase     ,				_UpperCAmelCase       ):
    __a		 =       [float('''inf'''       )] * vertex_count
    __a		 =       0.0

    for _ in range(vertex_count - 1       ):
        for j in range(_UpperCAmelCase       ):
            __a ,     __a ,     __a		 =       (graph[j][k] for k in ['''src''', '''dst''', '''weight'''])

            if distance[u] != float('''inf'''       ) and distance[u] + w < distance[v]:
                __a		 =       distance[u] + w

    __a		 =       check_negative_cycle(_UpperCAmelCase     ,				_UpperCAmelCase     ,				_UpperCAmelCase       )
    if negative_cycle_exists:
        raise Exception('''Negative cycle found'''       )

    return distance


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 __snake_case		:Dict   	=  int(input('''Enter number of vertices: ''').strip())
 __snake_case		:Any   	=  int(input('''Enter number of edges: ''').strip())

 __snake_case		:list[dict[str, int]]   	=  [{} for _ in range(E)]

 for i in range(E):
  print('''Edge ''', i + 1)
  __snake_case	,__snake_case	,__snake_case		:int   	=  (
      int(x)
      for x in input('''Enter source, destination, weight: ''').strip().split(''' ''')
  )
  __snake_case		:Any   	=  {'''src''': src, '''dst''': dest, '''weight''': weight}

 __snake_case		:List[str]   	=  int(input('''\nEnter shortest path source:''').strip())
 __snake_case		:Optional[Any]   	=  bellman_ford(graph, V, E, source)
 print_distance(shortest_distance, 0)





