



"""simple docstring"""




import unittest

import numpy as np

from transformers.file_utils import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
 import torch

if is_vision_available():
 from PIL import Image

 from transformers import DPTImageProcessor






class      UpperCAmelCase_  (    unittest.TestCase						):



      def __init__(					self					:     Optional[Any]					,     A					:     List[str]					,     A					:     Optional[Any]=7					,     A					:     Tuple=3					,     A					:     int=1_8					,     A					:     Optional[int]=3_0					,     A					:     Any=4_0_0					,     A					:     int=True					,     A					:     Optional[int]=None					,     A					:     Dict=True					,     A					:     Union[str, Any]=[0.5, 0.5, 0.5]					,     A					:     Optional[int]=[0.5, 0.5, 0.5]					,     ):
           _UpperCAmelCase      :     List[Any]        =   size if size is not None else {"height": 1_8, "width": 1_8}
           _UpperCAmelCase      :     Any        =   parent
           _UpperCAmelCase      :     int        =   batch_size
           _UpperCAmelCase      :     Optional[Any]        =   num_channels
           _UpperCAmelCase      :     Any        =   image_size
           _UpperCAmelCase      :     str        =   min_resolution
           _UpperCAmelCase      :     Dict        =   max_resolution
           _UpperCAmelCase      :     Any        =   do_resize
           _UpperCAmelCase      :     Union[str, Any]        =   size
           _UpperCAmelCase      :     Any        =   do_normalize
           _UpperCAmelCase      :     Any        =   image_mean
           _UpperCAmelCase      :     Optional[int]        =   image_std



      def 						snake_case_ (					self					:     Dict						):
           return {
               "image_mean": self.image_mean,
               "image_std": self.image_std,
               "do_normalize": self.do_normalize,
               "do_resize": self.do_resize,
               "size": self.size,
           }







@require_torch
@require_vision
class      UpperCAmelCase_  (    _UpperCamelCase	,      unittest.TestCase						):
      __SCREAMING_SNAKE_CASE						:       Optional[Any]								=			DPTImageProcessor if is_vision_available() else None



      def 						snake_case_ (					self					:     str						):
           _UpperCAmelCase      :     List[Any]        =   DPTImageProcessingTester(self						)



      @property
      def 						snake_case_ (					self					:     List[Any]						):
           return self.image_processor_tester.prepare_image_processor_dict()



      def 						snake_case_ (					self					:     int						):
           _UpperCAmelCase      :     str        =   self.image_processing_class(**self.image_processor_dict						)
           self.assertTrue(hasattr(A					,     "image_mean"						)						)
           self.assertTrue(hasattr(A					,     "image_std"						)						)
           self.assertTrue(hasattr(A					,     "do_normalize"						)						)
           self.assertTrue(hasattr(A					,     "do_resize"						)						)
           self.assertTrue(hasattr(A					,     "size"						)						)



      def 						snake_case_ (					self					:     int						):
           _UpperCAmelCase      :     Optional[Any]        =   self.image_processing_class.from_dict(self.image_processor_dict						)
           self.assertEqual(image_processor.size					,     {"height": 1_8, "width": 1_8}						)

           _UpperCAmelCase      :     List[Any]        =   self.image_processing_class.from_dict(self.image_processor_dict					,     size=4_2						)
           self.assertEqual(image_processor.size					,     {"height": 4_2, "width": 4_2}						)



      def 						snake_case_ (					self					:     Union[str, Any]						):
           # Initialize image_processing
           _UpperCAmelCase      :     List[str]        =   self.image_processing_class(**self.image_processor_dict						)
           # create random PIL images
           _UpperCAmelCase      :     Dict        =   prepare_image_inputs(self.image_processor_tester					,     equal_resolution=A						)
           for image in image_inputs:
                self.assertIsInstance(A					,     Image.Image						)

           # Test not batched input
           _UpperCAmelCase      :     List[str]        =   image_processing(image_inputs[0]					,     return_tensors="pt"						).pixel_values
           self.assertEqual(
               encoded_images.shape					,     (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,     )

           # Test batched
           _UpperCAmelCase      :     Any        =   image_processing(A					,     return_tensors="pt"						).pixel_values
           self.assertEqual(
               encoded_images.shape					,     (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,     )



      def 						snake_case_ (					self					:     Union[str, Any]						):
           # Initialize image_processing
           _UpperCAmelCase      :     int        =   self.image_processing_class(**self.image_processor_dict						)
           # create random numpy tensors
           _UpperCAmelCase      :     Dict        =   prepare_image_inputs(self.image_processor_tester					,     equal_resolution=A					,     numpify=A						)
           for image in image_inputs:
                self.assertIsInstance(A					,     np.ndarray						)

           # Test not batched input
           _UpperCAmelCase      :     Optional[int]        =   image_processing(image_inputs[0]					,     return_tensors="pt"						).pixel_values
           self.assertEqual(
               encoded_images.shape					,     (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,     )

           # Test batched
           _UpperCAmelCase      :     Tuple        =   image_processing(A					,     return_tensors="pt"						).pixel_values
           self.assertEqual(
               encoded_images.shape					,     (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,     )



      def 						snake_case_ (					self					:     Union[str, Any]						):
           # Initialize image_processing
           _UpperCAmelCase      :     Union[str, Any]        =   self.image_processing_class(**self.image_processor_dict						)
           # create random PyTorch tensors
           _UpperCAmelCase      :     str        =   prepare_image_inputs(self.image_processor_tester					,     equal_resolution=A					,     torchify=A						)
           for image in image_inputs:
                self.assertIsInstance(A					,     torch.Tensor						)

           # Test not batched input
           _UpperCAmelCase      :     Tuple        =   image_processing(image_inputs[0]					,     return_tensors="pt"						).pixel_values
           self.assertEqual(
               encoded_images.shape					,     (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,     )

           # Test batched
           _UpperCAmelCase      :     int        =   image_processing(A					,     return_tensors="pt"						).pixel_values
           self.assertEqual(
               encoded_images.shape					,     (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["height"],
                   self.image_processor_tester.size["width"],
               )					,     )





"""simple docstring"""




from __future__ import annotations

from typing import Any

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						list[Any]    )  ->       None:





     '''simple docstring'''

     create_state_space_tree(SCREAMING_SNAKE_CASE__						,  []						,  0    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						list[Any]						,  SCREAMING_SNAKE_CASE__     :						list[Any]						,  SCREAMING_SNAKE_CASE__     :						int    )  ->       None:





     '''simple docstring'''

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

     create_state_space_tree(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  index + 1    )
     current_subsequence.append(sequence[index]    )
     create_state_space_tree(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  index + 1    )
     current_subsequence.pop()


if __name__ == "__main__":
 _lowerCAmelCase    : list[Any]							=							[3, 1, 2, 4]
 generate_all_subsequences(seq)

 seq.clear()
 seq.extend(["A", "B", "C"])
 generate_all_subsequences(seq)
