



"""simple docstring"""





import unittest

import numpy as np

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

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 LevitImageProcessor




class 			lowercase__			(      unittest.TestCase    ):
							'''simple docstring'''







							def __init__(  self	,       snake_case	,       snake_case=7	,       snake_case=3	,       snake_case=18	,       snake_case=30	,       snake_case=400	,       snake_case=True	,       snake_case=None	,       snake_case=True	,       snake_case=None	,       snake_case=True	,       snake_case=[0.5, 0.5, 0.5]	,       snake_case=[0.5, 0.5, 0.5]	,       )			->							Optional[int]:
									_UpperCAmelCase							 =		size if size is not None else {'shortest_edge': 18}
									_UpperCAmelCase							 =		crop_size if crop_size is not None else {'height': 18, 'width': 18}
									_UpperCAmelCase							 =		parent
									_UpperCAmelCase							 =		batch_size
									_UpperCAmelCase							 =		num_channels
									_UpperCAmelCase							 =		image_size
									_UpperCAmelCase							 =		min_resolution
									_UpperCAmelCase							 =		max_resolution
									_UpperCAmelCase							 =		do_resize
									_UpperCAmelCase							 =		size
									_UpperCAmelCase							 =		do_center_crop
									_UpperCAmelCase							 =		crop_size
									_UpperCAmelCase							 =		do_normalize
									_UpperCAmelCase							 =		image_mean
									_UpperCAmelCase							 =		image_std






							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									return {
									    "image_mean": self.image_mean,
									    "image_std": self.image_std,
									    "do_normalize": self.do_normalize,
									    "do_resize": self.do_resize,
									    "do_center_crop": self.do_center_crop,
									    "size": self.size,
									    "crop_size": self.crop_size,
									}







@require_torch
@require_vision
class 			lowercase__			(      A,					unittest.TestCase    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					LevitImageProcessor if is_vision_available() else None






							def        lowerCamelCase_   (  self						)			->							Any:
									_UpperCAmelCase							 =		LevitImageProcessingTester(self						)






							@property
							def        lowerCamelCase_   (  self						)			->							str:
									return self.image_processor_tester.prepare_image_processor_dict()






							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									self.assertTrue(hasattr(snake_case	,       'image_mean'						)						)
									self.assertTrue(hasattr(snake_case	,       'image_std'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_normalize'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_resize'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_center_crop'						)						)
									self.assertTrue(hasattr(snake_case	,       'size'						)						)






							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		self.image_processing_class.from_dict(self.image_processor_dict						)
									self.assertEqual(image_processor.size	,       {'shortest_edge': 18}						)
									self.assertEqual(image_processor.crop_size	,       {'height': 18, 'width': 18}						)

									_UpperCAmelCase							 =		self.image_processing_class.from_dict(self.image_processor_dict	,       size=42	,       crop_size=84						)
									self.assertEqual(image_processor.size	,       {'shortest_edge': 42}						)
									self.assertEqual(image_processor.crop_size	,       {'height': 84, 'width': 84}						)






							def        lowerCamelCase_   (  self						)			->							Tuple:
									pass






							def        lowerCamelCase_   (  self						)			->							Optional[int]:
									# Initialize image_processing
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									# create random PIL images
									_UpperCAmelCase							 =		prepare_image_inputs(self.image_processor_tester	,       equal_resolution=snake_case						)
									for image in image_inputs:
											self.assertIsInstance(snake_case	,       Image.Image						)

									# Test not batched input
									_UpperCAmelCase							 =		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.crop_size['height'],
									        self.image_processor_tester.crop_size['width'],
									    )	,       )

									# Test batched
									_UpperCAmelCase							 =		image_processing(snake_case	,       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.crop_size['height'],
									        self.image_processor_tester.crop_size['width'],
									    )	,       )






							def        lowerCamelCase_   (  self						)			->							Tuple:
									# Initialize image_processing
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									# create random numpy tensors
									_UpperCAmelCase							 =		prepare_image_inputs(self.image_processor_tester	,       equal_resolution=snake_case	,       numpify=snake_case						)
									for image in image_inputs:
											self.assertIsInstance(snake_case	,       np.ndarray						)

									# Test not batched input
									_UpperCAmelCase							 =		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.crop_size['height'],
									        self.image_processor_tester.crop_size['width'],
									    )	,       )

									# Test batched
									_UpperCAmelCase							 =		image_processing(snake_case	,       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.crop_size['height'],
									        self.image_processor_tester.crop_size['width'],
									    )	,       )






							def        lowerCamelCase_   (  self						)			->							Tuple:
									# Initialize image_processing
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									# create random PyTorch tensors
									_UpperCAmelCase							 =		prepare_image_inputs(self.image_processor_tester	,       equal_resolution=snake_case	,       torchify=snake_case						)
									for image in image_inputs:
											self.assertIsInstance(snake_case	,       torch.Tensor						)

									# Test not batched input
									_UpperCAmelCase							 =		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.crop_size['height'],
									        self.image_processor_tester.crop_size['width'],
									    )	,       )

									# Test batched
									_UpperCAmelCase							 =		image_processing(snake_case	,       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.crop_size['height'],
									        self.image_processor_tester.crop_size['width'],
									    )	,       )







"""simple docstring"""





from __future__ import annotations




def 	UpperCAmelCase     (		A	:						int     ,				A	:						int       ):

		'''simple docstring'''


		_UpperCAmelCase							 =		[]
		create_all_state(1     ,				A     ,				A     ,				[]     ,				A       )
		return result




def 	UpperCAmelCase     (		A	:						int     ,				A	:						int     ,				A	:						int     ,				A	:						list[int]     ,				A	:						list[list[int]]     ,				):

		'''simple docstring'''


		if level == 0:
				total_list.append(current_list[:]       )
				return

		for i in range(A     ,				total_number - level + 2       ):
				current_list.append(A       )
				create_all_state(i + 1     ,				A     ,				level - 1     ,				A     ,				A       )
				current_list.pop()




def 	UpperCAmelCase     (		A	:						list[list[int]]       ):

		'''simple docstring'''


		for i in total_list:
				print(*A       )


if __name__ == "__main__":
					lowercase  							=					4
					lowercase  							=					2
					lowercase  							=					generate_all_combinations(n, k)
					print_all_state(total_list)


