





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





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							10





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      Dict     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

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





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

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							""""""
      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							process_story(lowerCamelCase     )
      self.assertEqual(lowerCamelCase					,[]     )
      self.assertEqual(lowerCamelCase					,[]     )





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							(
          """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"""
      )
      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							process_story(lowerCamelCase     )

      __SCREAMING_SNAKE_CASE   				=							[
          """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     )

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





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

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      str     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      List[str]     ):

      '''simple docstring'''

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

      __SCREAMING_SNAKE_CASE   				=							compute_token_type_ids(lowerCamelCase					,lowerCamelCase     )
      np.testing.assert_array_equal(lowerCamelCase					,lowerCamelCase     )









from PIL import Image




def    a__    (		snake_case__					:							Image						,   snake_case__					:							int     ):
  _UpperCAmelCase		:							Optional[Any]							=     (259 * (level + 255)) / (255 * (259 - level))

  def contrast(snake_case__					:							int     ) -> int:
    return int(128 + factor * (c - 128)     )

  return img.point(snake_case__     )


if __name__ == "__main__":
 # Load image
 with Image.open('image_data/lena.jpg') as img:
  # Change contrast to 170
  SCREAMING_SNAKE_CASE__					:     int       =     change_contrast(img, 170)
  cont_img.save('image_data/lena_high_contrast.png', format='png')





