


from __future__ import annotations






def 			__lowerCAmelCase       (SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )->    list:




      """simple docstring"""

      snake_case_			= [None] * (len(SCREAMING_SNAKE_CASE   ) + len(SCREAMING_SNAKE_CASE   ))

      snake_case_			= 0  # pointer to current index for left Half
      snake_case_			= 0  # pointer to current index for the right Half
      snake_case_			= 0  # pointer to current index for the sorted array Half

      while pointera < len(SCREAMING_SNAKE_CASE   ) and pointera < len(SCREAMING_SNAKE_CASE   ):
            if left_half[pointera] < right_half[pointera]:
                  snake_case_			= left_half[pointera]
                  pointera += 1
                  index += 1
            else:
                  snake_case_			= right_half[pointera]
                  pointera += 1
                  index += 1
      while pointera < len(SCREAMING_SNAKE_CASE   ):
            snake_case_			= left_half[pointera]
            pointera += 1
            index += 1

      while pointera < len(SCREAMING_SNAKE_CASE   ):
            snake_case_			= right_half[pointera]
            pointera += 1
            index += 1

      return sorted_array






def 			__lowerCAmelCase       (SCREAMING_SNAKE_CASE   )->    list:




      """simple docstring"""

      if len(SCREAMING_SNAKE_CASE   ) <= 1:
            return array
      # the actual formula to calculate the middle element = left + (right - left) // 2
      # this avoids integer overflow in case of large N
      snake_case_			= 0 + (len(SCREAMING_SNAKE_CASE   ) - 0) // 2

      # Split the array into halves till the array length becomes equal to One
      # merge the arrays of single length returned by mergeSort function and
      # pass them into the merge arrays function which merges the array
      snake_case_			= array[:middle]
      snake_case_			= array[middle:]

      return merge(merge_sort(SCREAMING_SNAKE_CASE   )   ,   merge_sort(SCREAMING_SNAKE_CASE   )   )


if __name__ == "__main__":
   import doctest

   doctest.testmod()



import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
   from PIL import Image







class lowerCAmelCase_		(					unittest.TestCase   ,		lowerCamelCase__			):

 '''simple docstring'''

 def 		UpperCamelCase__	(      self   ):
       snake_case_			= load_tool('''image-question-answering'''   )
       self.tool.setup()
       snake_case_			= load_tool('''image-question-answering'''						, remote=_UpperCAmelCase   )



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.tool(_UpperCAmelCase						, '''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.remote_tool(_UpperCAmelCase						, '''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )



 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.tool(image=_UpperCAmelCase						, question='''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )





 def 		UpperCamelCase__	(      self   ):
       snake_case_			= Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''   )   ) / '''000000039769.png'''   )
       snake_case_			= self.remote_tool(image=_UpperCAmelCase						, question='''How many cats are sleeping on the couch?'''   )
       self.assertEqual(_UpperCAmelCase						, '''2'''   )