import unittest

from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
   from PIL import Image
else:







   class   lowerCamelCase	:





        @staticmethod
        def 	UpperCAmelCase(*_A   :					Optional[int]       ,					**_A   :					Dict     )		->		List[Any]:
            pass







@is_pipeline_test
@require_vision
@require_torch
class   lowerCamelCase	(						unittest.TestCase						):
     UpperCAmelCase__       :							Union[str, Any]     =	MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING





     def 	UpperCAmelCase(self   :					str       ,					_A   :					List[Any]       ,					_A   :					Dict       ,					_A   :					Optional[int]     )		->		Tuple:
         snake_case				  =      pipeline(
             "zero-shot-object-detection"       ,					model="hf-internal-testing/tiny-random-owlvit-object-detection"     )

         snake_case				  =      [
             {
                 "image": "./tests/fixtures/tests_samples/COCO/000000039769.png",
                 "candidate_labels": ["cat", "remote", "couch"],
             }
         ]
         return object_detector, examples





     def 	UpperCAmelCase(self   :					List[str]       ,					_A   :					List[str]       ,					_A   :					Tuple     )		->		Any:
         snake_case				  =      object_detector(examples[0]       ,					threshold=0.0     )

         snake_case				  =      len(_A     )
         self.assertGreater(_A       ,					0     )
         self.assertEqual(
             _A       ,					[
                 {
                     "score": ANY(_A     ),
                     "label": ANY(_A     ),
                     "box": {"xmin": ANY(_A     ), "ymin": ANY(_A     ), "xmax": ANY(_A     ), "ymax": ANY(_A     )},
                 }
                 for i in range(_A     )
             ]       ,					)





     @require_tf
     @unittest.skip("Zero Shot Object Detection not implemented in TF"     )
     def 	UpperCAmelCase(self   :					Dict     )		->		str:
         pass





     @require_torch
     def 	UpperCAmelCase(self   :					Union[str, Any]     )		->		Tuple:
         snake_case				  =      pipeline(
             "zero-shot-object-detection"       ,					model="hf-internal-testing/tiny-random-owlvit-object-detection"     )

         snake_case				  =      object_detector(
             "./tests/fixtures/tests_samples/COCO/000000039769.png"       ,					candidate_labels=["cat", "remote", "couch"]       ,					threshold=0.64       ,					)

         self.assertEqual(
             nested_simplify(_A       ,					decimals=4     )       ,					[
                 {"score": 0.72_35, "label": "cat", "box": {"xmin": 2_0_4, "ymin": 1_6_7, "xmax": 2_3_2, "ymax": 1_9_0}},
                 {"score": 0.72_18, "label": "remote", "box": {"xmin": 2_0_4, "ymin": 1_6_7, "xmax": 2_3_2, "ymax": 1_9_0}},
                 {"score": 0.71_84, "label": "couch", "box": {"xmin": 2_0_4, "ymin": 1_6_7, "xmax": 2_3_2, "ymax": 1_9_0}},
                 {"score": 0.67_48, "label": "remote", "box": {"xmin": 5_7_1, "ymin": 8_3, "xmax": 5_9_8, "ymax": 1_0_3}},
                 {"score": 0.66_56, "label": "cat", "box": {"xmin": 5_7_1, "ymin": 8_3, "xmax": 5_9_8, "ymax": 1_0_3}},
                 {"score": 0.66_14, "label": "couch", "box": {"xmin": 5_7_1, "ymin": 8_3, "xmax": 5_9_8, "ymax": 1_0_3}},
                 {"score": 0.64_56, "label": "remote", "box": {"xmin": 4_9_4, "ymin": 1_0_5, "xmax": 5_2_1, "ymax": 1_2_7}},
                 {"score": 0.6_42, "label": "remote", "box": {"xmin": 6_7, "ymin": 2_7_4, "xmax": 9_3, "ymax": 2_9_7}},
                 {"score": 0.64_19, "label": "cat", "box": {"xmin": 4_9_4, "ymin": 1_0_5, "xmax": 5_2_1, "ymax": 1_2_7}},
             ]       ,					)

         snake_case				  =      object_detector(
             [
                 {
                     "image": "./tests/fixtures/tests_samples/COCO/000000039769.png",
                     "candidate_labels": ["cat", "remote", "couch"],
                 }
             ]       ,					threshold=0.64       ,					)

         self.assertEqual(
             nested_simplify(_A       ,					decimals=4     )       ,					[
                 [
                     {"score": 0.72_35, "label": "cat", "box": {"xmin": 2_0_4, "ymin": 1_6_7, "xmax": 2_3_2, "ymax": 1_9_0}},
                     {"score": 0.72_18, "label": "remote", "box": {"xmin": 2_0_4, "ymin": 1_6_7, "xmax": 2_3_2, "ymax": 1_9_0}},
                     {"score": 0.71_84, "label": "couch", "box": {"xmin": 2_0_4, "ymin": 1_6_7, "xmax": 2_3_2, "ymax": 1_9_0}},
                     {"score": 0.67_48, "label": "remote", "box": {"xmin": 5_7_1, "ymin": 8_3, "xmax": 5_9_8, "ymax": 1_0_3}},
                     {"score": 0.66_56, "label": "cat", "box": {"xmin": 5_7_1, "ymin": 8_3, "xmax": 5_9_8, "ymax": 1_0_3}},
                     {"score": 0.66_14, "label": "couch", "box": {"xmin": 5_7_1, "ymin": 8_3, "xmax": 5_9_8, "ymax": 1_0_3}},
                     {"score": 0.64_56, "label": "remote", "box": {"xmin": 4_9_4, "ymin": 1_0_5, "xmax": 5_2_1, "ymax": 1_2_7}},
                     {"score": 0.6_42, "label": "remote", "box": {"xmin": 6_7, "ymin": 2_7_4, "xmax": 9_3, "ymax": 2_9_7}},
                     {"score": 0.64_19, "label": "cat", "box": {"xmin": 4_9_4, "ymin": 1_0_5, "xmax": 5_2_1, "ymax": 1_2_7}},
                 ]
             ]       ,					)





     @require_torch
     @slow
     def 	UpperCAmelCase(self   :					List[Any]     )		->		Union[str, Any]:
         snake_case				  =      pipeline("zero-shot-object-detection"     )

         snake_case				  =      object_detector(
             "http://images.cocodataset.org/val2017/000000039769.jpg"       ,					candidate_labels=["cat", "remote", "couch"]       ,					)
         self.assertEqual(
             nested_simplify(_A       ,					decimals=4     )       ,					[
                 {"score": 0.28_68, "label": "cat", "box": {"xmin": 3_2_4, "ymin": 2_0, "xmax": 6_4_0, "ymax": 3_7_3}},
                 {"score": 0.2_77, "label": "remote", "box": {"xmin": 4_0, "ymin": 7_2, "xmax": 1_7_7, "ymax": 1_1_5}},
                 {"score": 0.25_37, "label": "cat", "box": {"xmin": 1, "ymin": 5_5, "xmax": 3_1_5, "ymax": 4_7_2}},
                 {"score": 0.14_74, "label": "remote", "box": {"xmin": 3_3_5, "ymin": 7_4, "xmax": 3_7_1, "ymax": 1_8_7}},
                 {"score": 0.12_08, "label": "couch", "box": {"xmin": 4, "ymin": 0, "xmax": 6_4_2, "ymax": 4_7_6}},
             ]       ,					)

         snake_case				  =      object_detector(
             [
                 {
                     "image": "http://images.cocodataset.org/val2017/000000039769.jpg",
                     "candidate_labels": ["cat", "remote", "couch"],
                 },
                 {
                     "image": "http://images.cocodataset.org/val2017/000000039769.jpg",
                     "candidate_labels": ["cat", "remote", "couch"],
                 },
             ]       ,					)
         self.assertEqual(
             nested_simplify(_A       ,					decimals=4     )       ,					[
                 [
                     {"score": 0.28_68, "label": "cat", "box": {"xmin": 3_2_4, "ymin": 2_0, "xmax": 6_4_0, "ymax": 3_7_3}},
                     {"score": 0.2_77, "label": "remote", "box": {"xmin": 4_0, "ymin": 7_2, "xmax": 1_7_7, "ymax": 1_1_5}},
                     {"score": 0.25_37, "label": "cat", "box": {"xmin": 1, "ymin": 5_5, "xmax": 3_1_5, "ymax": 4_7_2}},
                     {"score": 0.14_74, "label": "remote", "box": {"xmin": 3_3_5, "ymin": 7_4, "xmax": 3_7_1, "ymax": 1_8_7}},
                     {"score": 0.12_08, "label": "couch", "box": {"xmin": 4, "ymin": 0, "xmax": 6_4_2, "ymax": 4_7_6}},
                 ],
                 [
                     {"score": 0.28_68, "label": "cat", "box": {"xmin": 3_2_4, "ymin": 2_0, "xmax": 6_4_0, "ymax": 3_7_3}},
                     {"score": 0.2_77, "label": "remote", "box": {"xmin": 4_0, "ymin": 7_2, "xmax": 1_7_7, "ymax": 1_1_5}},
                     {"score": 0.25_37, "label": "cat", "box": {"xmin": 1, "ymin": 5_5, "xmax": 3_1_5, "ymax": 4_7_2}},
                     {"score": 0.14_74, "label": "remote", "box": {"xmin": 3_3_5, "ymin": 7_4, "xmax": 3_7_1, "ymax": 1_8_7}},
                     {"score": 0.12_08, "label": "couch", "box": {"xmin": 4, "ymin": 0, "xmax": 6_4_2, "ymax": 4_7_6}},
                 ],
             ]       ,					)





     @require_tf
     @unittest.skip("Zero Shot Object Detection not implemented in TF"     )
     def 	UpperCAmelCase(self   :					Tuple     )		->		List[str]:
         pass





     @require_torch
     @slow
     def 	UpperCAmelCase(self   :					Union[str, Any]     )		->		Dict:
         snake_case				  =      0.2
         snake_case				  =      pipeline("zero-shot-object-detection"     )

         snake_case				  =      object_detector(
             "http://images.cocodataset.org/val2017/000000039769.jpg"       ,					candidate_labels=["cat", "remote", "couch"]       ,					threshold=_A       ,					)
         self.assertEqual(
             nested_simplify(_A       ,					decimals=4     )       ,					[
                 {"score": 0.28_68, "label": "cat", "box": {"xmin": 3_2_4, "ymin": 2_0, "xmax": 6_4_0, "ymax": 3_7_3}},
                 {"score": 0.2_77, "label": "remote", "box": {"xmin": 4_0, "ymin": 7_2, "xmax": 1_7_7, "ymax": 1_1_5}},
                 {"score": 0.25_37, "label": "cat", "box": {"xmin": 1, "ymin": 5_5, "xmax": 3_1_5, "ymax": 4_7_2}},
             ]       ,					)





     @require_torch
     @slow
     def 	UpperCAmelCase(self   :					List[str]     )		->		List[Any]:
         snake_case				  =      2
         snake_case				  =      pipeline("zero-shot-object-detection"     )

         snake_case				  =      object_detector(
             "http://images.cocodataset.org/val2017/000000039769.jpg"       ,					candidate_labels=["cat", "remote", "couch"]       ,					top_k=_A       ,					)
         self.assertEqual(
             nested_simplify(_A       ,					decimals=4     )       ,					[
                 {"score": 0.28_68, "label": "cat", "box": {"xmin": 3_2_4, "ymin": 2_0, "xmax": 6_4_0, "ymax": 3_7_3}},
                 {"score": 0.2_77, "label": "remote", "box": {"xmin": 4_0, "ymin": 7_2, "xmax": 1_7_7, "ymax": 1_1_5}},
             ]       ,					)



import sys

_A						      =				(
    "73167176531330624919225119674426574742355349194934"
    "96983520312774506326239578318016984801869478851843"
    "85861560789112949495459501737958331952853208805511"
    "12540698747158523863050715693290963295227443043557"
    "66896648950445244523161731856403098711121722383113"
    "62229893423380308135336276614282806444486645238749"
    "30358907296290491560440772390713810515859307960866"
    "70172427121883998797908792274921901699720888093776"
    "65727333001053367881220235421809751254540594752243"
    "52584907711670556013604839586446706324415722155397"
    "53697817977846174064955149290862569321978468622482"
    "83972241375657056057490261407972968652414535100474"
    "82166370484403199890008895243450658541227588666881"
    "16427171479924442928230863465674813919123162824586"
    "17866458359124566529476545682848912883142607690042"
    "24219022671055626321111109370544217506941658960408"
    "07198403850962455444362981230987879927244284909188"
    "84580156166097919133875499200524063689912560717606"
    "05886116467109405077541002256983155200055935729725"
    "71636269561882670428252483600823257530420752963450"
)



def 		lowercase_    (     A__	)							->							int:
    """simple docstring"""

    snake_case				  =      1
    for digit in s:
        product *= int(A__	)
    return product



def 		lowercase_    (     A__ = N	)							->							int:
    """simple docstring"""

    snake_case				  =      -sys.maxsize - 1
    snake_case				  =      n[:13]
    snake_case				  =      13
    while cur_index < len(A__	) - 13:
        if int(n[cur_index]	) >= int(substr[0]	):
            snake_case				  =      substr[1:] + n[cur_index]
            cur_index += 1
        else:
            snake_case				  =      max(A__				,	str_eval(A__	)	)
            snake_case				  =      n[cur_index : cur_index + 13]
            cur_index += 13
    return largest_product


if __name__ == "__main__":
   print(f"{solution() = }")

