


import unittest

from datasets import load_dataset

from transformers import load_tool

from .test_tools_common import ToolTesterMixin






class        UpperCAmelCase__			(   unittest.TestCase  ,    A_						):



    """simple docstring"""






    def _a   (     self       )    ->			str:
         __UpperCamelCase       				=load_tool('document-question-answering'       )
         self.tool.setup()
         __UpperCamelCase       				=load_tool('document-question-answering'   ,  remote=A_       )






    def _a   (     self       )    ->			List[Any]:
         __UpperCamelCase       				=load_dataset('hf-internal-testing/example-documents'   ,  split='test'       )
         __UpperCamelCase       				=dataset[0]['image']

         __UpperCamelCase       				=self.tool(A_   ,  'When is the coffee break?'       )
         self.assertEqual(A_   ,  '11-14 to 11:39 a.m.'       )






    def _a   (     self       )    ->			List[Any]:
         __UpperCamelCase       				=load_dataset('hf-internal-testing/example-documents'   ,  split='test'       )
         __UpperCamelCase       				=dataset[0]['image']

         __UpperCamelCase       				=self.remote_tool(A_   ,  'When is the coffee break?'       )
         self.assertEqual(A_   ,  '11-14 to 11:39 a.m.'       )






    def _a   (     self       )    ->			Dict:
         __UpperCamelCase       				=load_dataset('hf-internal-testing/example-documents'   ,  split='test'       )
         __UpperCamelCase       				=dataset[0]['image']

         self.tool(document=A_   ,  question='When is the coffee break?'       )






    def _a   (     self       )    ->			int:
         __UpperCamelCase       				=load_dataset('hf-internal-testing/example-documents'   ,  split='test'       )
         __UpperCamelCase       				=dataset[0]['image']

         __UpperCamelCase       				=self.remote_tool(document=A_   ,  question='When is the coffee break?'       )
         self.assertEqual(A_   ,  '11-14 to 11:39 a.m.'       )









def 		_UpperCAmelCase							(     SCREAMING_SNAKE_CASE__     :   list     ,	SCREAMING_SNAKE_CASE__     :   int     ,	SCREAMING_SNAKE_CASE__     :   int     ,	SCREAMING_SNAKE_CASE__     :   int							):
     __UpperCamelCase       				=int((lower_bound + upper_bound) // 2							)
     if array[r] == value:
          return r
     if lower_bound >= upper_bound:
          return -1
     if array[r] < value:
          return binary_search(SCREAMING_SNAKE_CASE__     ,	r + 1     ,	SCREAMING_SNAKE_CASE__     ,	SCREAMING_SNAKE_CASE__							)
     else:
          return binary_search(SCREAMING_SNAKE_CASE__     ,	SCREAMING_SNAKE_CASE__     ,	r - 1     ,	SCREAMING_SNAKE_CASE__							)

def 		_UpperCAmelCase							(     SCREAMING_SNAKE_CASE__     :   int     ,	SCREAMING_SNAKE_CASE__     :   list							):
     __UpperCamelCase       				=0
     if matrix[index][0] == value:
          return [index, 0]
     while index < len(SCREAMING_SNAKE_CASE__							) and matrix[index][0] < value:
          __UpperCamelCase       				=binary_search(matrix[index]     ,	0     ,	len(matrix[index]							) - 1     ,	SCREAMING_SNAKE_CASE__							)
          if r != -1:
               return [index, r]
          index += 1
     return [-1, -1]


if __name__ == "__main__":
   import doctest

   doctest.testmod()





