

'''simple docstring'''


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      a      :






											"""simple docstring"""




											@staticmethod
											def    __magic_name__				(				*snake_case_       :   Optional[int]      ,      **snake_case_       :   Tuple	):



													'''simple docstring'''



													pass




@is_pipeline_test
@require_vision
@require_torch
class      a      (					unittest.TestCase							):






						"""simple docstring"""




						__UpperCAmelCase        =     MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING







						def    __magic_name__				(				self       :   Tuple      ,      snake_case_       :   int      ,      snake_case_       :   Any      ,      snake_case_       :   Any	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	pipeline(
								    '''zero-shot-object-detection'''      ,      model='''hf-internal-testing/tiny-random-owlvit-object-detection'''	)

								snake_case__    :							Optional[Any]							    =	[
								    {
								        '''image''': '''./tests/fixtures/tests_samples/COCO/000000039769.png''',
								        '''candidate_labels''': ['''cat''', '''remote''', '''couch'''],
								    }
								]
								return object_detector, examples







						def    __magic_name__				(				self       :   int      ,      snake_case_       :   str      ,      snake_case_       :   str	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	object_detector(examples[0]      ,      threshold=0.0	)

								snake_case__    :							Optional[Any]							    =	len(_lowerCamelCase	)
								self.assertGreater(_lowerCamelCase      ,      0	)
								self.assertEqual(
								    _lowerCamelCase      ,      [
								        {
								            '''score''': ANY(_lowerCamelCase	),
								            '''label''': ANY(_lowerCamelCase	),
								            '''box''': {'''xmin''': ANY(_lowerCamelCase	), '''ymin''': ANY(_lowerCamelCase	), '''xmax''': ANY(_lowerCamelCase	), '''ymax''': ANY(_lowerCamelCase	)},
								        }
								        for i in range(_lowerCamelCase	)
								    ]      ,      )







						@require_tf
						@unittest.skip('''Zero Shot Object Detection not implemented in TF'''	)
						def    __magic_name__				(				self       :   Optional[int]	):



								'''simple docstring'''



								pass







						@require_torch
						def    __magic_name__				(				self       :   Union[str, Any]	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	pipeline(
								    '''zero-shot-object-detection'''      ,      model='''hf-internal-testing/tiny-random-owlvit-object-detection'''	)

								snake_case__    :							str							    =	object_detector(
								    '''./tests/fixtures/tests_samples/COCO/000000039769.png'''      ,      candidate_labels=['''cat''', '''remote''', '''couch''']      ,      threshold=0.6_4      ,      )

								self.assertEqual(
								    nested_simplify(_lowerCamelCase      ,      decimals=4	)      ,      [
								        {'''score''': 0.7_2_3_5, '''label''': '''cat''', '''box''': {'''xmin''': 2_0_4, '''ymin''': 1_6_7, '''xmax''': 2_3_2, '''ymax''': 1_9_0}},
								        {'''score''': 0.7_2_1_8, '''label''': '''remote''', '''box''': {'''xmin''': 2_0_4, '''ymin''': 1_6_7, '''xmax''': 2_3_2, '''ymax''': 1_9_0}},
								        {'''score''': 0.7_1_8_4, '''label''': '''couch''', '''box''': {'''xmin''': 2_0_4, '''ymin''': 1_6_7, '''xmax''': 2_3_2, '''ymax''': 1_9_0}},
								        {'''score''': 0.6_7_4_8, '''label''': '''remote''', '''box''': {'''xmin''': 5_7_1, '''ymin''': 8_3, '''xmax''': 5_9_8, '''ymax''': 1_0_3}},
								        {'''score''': 0.6_6_5_6, '''label''': '''cat''', '''box''': {'''xmin''': 5_7_1, '''ymin''': 8_3, '''xmax''': 5_9_8, '''ymax''': 1_0_3}},
								        {'''score''': 0.6_6_1_4, '''label''': '''couch''', '''box''': {'''xmin''': 5_7_1, '''ymin''': 8_3, '''xmax''': 5_9_8, '''ymax''': 1_0_3}},
								        {'''score''': 0.6_4_5_6, '''label''': '''remote''', '''box''': {'''xmin''': 4_9_4, '''ymin''': 1_0_5, '''xmax''': 5_2_1, '''ymax''': 1_2_7}},
								        {'''score''': 0.6_4_2, '''label''': '''remote''', '''box''': {'''xmin''': 6_7, '''ymin''': 2_7_4, '''xmax''': 9_3, '''ymax''': 2_9_7}},
								        {'''score''': 0.6_4_1_9, '''label''': '''cat''', '''box''': {'''xmin''': 4_9_4, '''ymin''': 1_0_5, '''xmax''': 5_2_1, '''ymax''': 1_2_7}},
								    ]      ,      )

								snake_case__    :							str							    =	object_detector(
								    [
								        {
								            '''image''': '''./tests/fixtures/tests_samples/COCO/000000039769.png''',
								            '''candidate_labels''': ['''cat''', '''remote''', '''couch'''],
								        }
								    ]      ,      threshold=0.6_4      ,      )

								self.assertEqual(
								    nested_simplify(_lowerCamelCase      ,      decimals=4	)      ,      [
								        [
								            {'''score''': 0.7_2_3_5, '''label''': '''cat''', '''box''': {'''xmin''': 2_0_4, '''ymin''': 1_6_7, '''xmax''': 2_3_2, '''ymax''': 1_9_0}},
								            {'''score''': 0.7_2_1_8, '''label''': '''remote''', '''box''': {'''xmin''': 2_0_4, '''ymin''': 1_6_7, '''xmax''': 2_3_2, '''ymax''': 1_9_0}},
								            {'''score''': 0.7_1_8_4, '''label''': '''couch''', '''box''': {'''xmin''': 2_0_4, '''ymin''': 1_6_7, '''xmax''': 2_3_2, '''ymax''': 1_9_0}},
								            {'''score''': 0.6_7_4_8, '''label''': '''remote''', '''box''': {'''xmin''': 5_7_1, '''ymin''': 8_3, '''xmax''': 5_9_8, '''ymax''': 1_0_3}},
								            {'''score''': 0.6_6_5_6, '''label''': '''cat''', '''box''': {'''xmin''': 5_7_1, '''ymin''': 8_3, '''xmax''': 5_9_8, '''ymax''': 1_0_3}},
								            {'''score''': 0.6_6_1_4, '''label''': '''couch''', '''box''': {'''xmin''': 5_7_1, '''ymin''': 8_3, '''xmax''': 5_9_8, '''ymax''': 1_0_3}},
								            {'''score''': 0.6_4_5_6, '''label''': '''remote''', '''box''': {'''xmin''': 4_9_4, '''ymin''': 1_0_5, '''xmax''': 5_2_1, '''ymax''': 1_2_7}},
								            {'''score''': 0.6_4_2, '''label''': '''remote''', '''box''': {'''xmin''': 6_7, '''ymin''': 2_7_4, '''xmax''': 9_3, '''ymax''': 2_9_7}},
								            {'''score''': 0.6_4_1_9, '''label''': '''cat''', '''box''': {'''xmin''': 4_9_4, '''ymin''': 1_0_5, '''xmax''': 5_2_1, '''ymax''': 1_2_7}},
								        ]
								    ]      ,      )







						@require_torch
						@slow
						def    __magic_name__				(				self       :   Union[str, Any]	):



								'''simple docstring'''



								snake_case__    :							Dict							    =	pipeline('''zero-shot-object-detection'''	)

								snake_case__    :							Dict							    =	object_detector(
								    '''http://images.cocodataset.org/val2017/000000039769.jpg'''      ,      candidate_labels=['''cat''', '''remote''', '''couch''']      ,      )
								self.assertEqual(
								    nested_simplify(_lowerCamelCase      ,      decimals=4	)      ,      [
								        {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_2_4, '''ymin''': 2_0, '''xmax''': 6_4_0, '''ymax''': 3_7_3}},
								        {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 4_0, '''ymin''': 7_2, '''xmax''': 1_7_7, '''ymax''': 1_1_5}},
								        {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 5_5, '''xmax''': 3_1_5, '''ymax''': 4_7_2}},
								        {'''score''': 0.1_4_7_4, '''label''': '''remote''', '''box''': {'''xmin''': 3_3_5, '''ymin''': 7_4, '''xmax''': 3_7_1, '''ymax''': 1_8_7}},
								        {'''score''': 0.1_2_0_8, '''label''': '''couch''', '''box''': {'''xmin''': 4, '''ymin''': 0, '''xmax''': 6_4_2, '''ymax''': 4_7_6}},
								    ]      ,      )

								snake_case__    :							Optional[Any]							    =	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(_lowerCamelCase      ,      decimals=4	)      ,      [
								        [
								            {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_2_4, '''ymin''': 2_0, '''xmax''': 6_4_0, '''ymax''': 3_7_3}},
								            {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 4_0, '''ymin''': 7_2, '''xmax''': 1_7_7, '''ymax''': 1_1_5}},
								            {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 5_5, '''xmax''': 3_1_5, '''ymax''': 4_7_2}},
								            {'''score''': 0.1_4_7_4, '''label''': '''remote''', '''box''': {'''xmin''': 3_3_5, '''ymin''': 7_4, '''xmax''': 3_7_1, '''ymax''': 1_8_7}},
								            {'''score''': 0.1_2_0_8, '''label''': '''couch''', '''box''': {'''xmin''': 4, '''ymin''': 0, '''xmax''': 6_4_2, '''ymax''': 4_7_6}},
								        ],
								        [
								            {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_2_4, '''ymin''': 2_0, '''xmax''': 6_4_0, '''ymax''': 3_7_3}},
								            {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 4_0, '''ymin''': 7_2, '''xmax''': 1_7_7, '''ymax''': 1_1_5}},
								            {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 5_5, '''xmax''': 3_1_5, '''ymax''': 4_7_2}},
								            {'''score''': 0.1_4_7_4, '''label''': '''remote''', '''box''': {'''xmin''': 3_3_5, '''ymin''': 7_4, '''xmax''': 3_7_1, '''ymax''': 1_8_7}},
								            {'''score''': 0.1_2_0_8, '''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    __magic_name__				(				self       :   Optional[Any]	):



								'''simple docstring'''



								pass







						@require_torch
						@slow
						def    __magic_name__				(				self       :   Any	):



								'''simple docstring'''



								snake_case__    :							Optional[Any]							    =	0.2
								snake_case__    :							Optional[int]							    =	pipeline('''zero-shot-object-detection'''	)

								snake_case__    :							int							    =	object_detector(
								    '''http://images.cocodataset.org/val2017/000000039769.jpg'''      ,      candidate_labels=['''cat''', '''remote''', '''couch''']      ,      threshold=_lowerCamelCase      ,      )
								self.assertEqual(
								    nested_simplify(_lowerCamelCase      ,      decimals=4	)      ,      [
								        {'''score''': 0.2_8_6_8, '''label''': '''cat''', '''box''': {'''xmin''': 3_2_4, '''ymin''': 2_0, '''xmax''': 6_4_0, '''ymax''': 3_7_3}},
								        {'''score''': 0.2_7_7, '''label''': '''remote''', '''box''': {'''xmin''': 4_0, '''ymin''': 7_2, '''xmax''': 1_7_7, '''ymax''': 1_1_5}},
								        {'''score''': 0.2_5_3_7, '''label''': '''cat''', '''box''': {'''xmin''': 1, '''ymin''': 5_5, '''xmax''': 3_1_5, '''ymax''': 4_7_2}},
								    ]      ,      )







						@require_torch
						@slow
						def    __magic_name__				(				self       :   List[str]	):



								'''simple docstring'''



								snake_case__    :							Tuple							    =	2
								snake_case__    :							int							    =	pipeline('''zero-shot-object-detection'''	)

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




'''simple docstring'''

from __future__ import annotations



def snake_case_      (					__snake_case  :							list[int | str])			->					None:
   create_state_space_tree(__snake_case	,   []	,   0	,   [0 for i in range(len(__snake_case))])



def snake_case_      (					__snake_case  :							list[int | str]	,   __snake_case  :							list[int | str]	,   __snake_case  :							int	,   __snake_case  :							list[int]	,   )			->					None:

   if index == len(__snake_case):
      print(__snake_case)
      return

   for i in range(len(__snake_case)):
      if not index_used[i]:
         current_sequence.append(sequence[i])
         lowerCAmelCase_			=      True
         create_state_space_tree(__snake_case	,   __snake_case	,   index + 1	,   __snake_case)
         current_sequence.pop()
         lowerCAmelCase_			=      False
A_     :						list[int | str]    							=[3, 1, 2, 4]
generate_all_permutations(sequence)

A_     :						list[int | str]    							=["A", "B", "C"]






generate_all_permutations(sequence_a)





