




'''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


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import BlipImageProcessor





class __magic_name__(						unittest.TestCase      ):






						def __init__(   self						:						Optional[int]					,   __UpperCamelCase						:						Optional[Any]					,   __UpperCamelCase						:						List[Any]=7					,   __UpperCamelCase						:						Union[str, Any]=3					,   __UpperCamelCase						:						Any=1_8					,   __UpperCamelCase						:						Union[str, Any]=3_0					,   __UpperCamelCase						:						Tuple=4_0_0					,   __UpperCamelCase						:						Any=True					,   __UpperCamelCase						:						Optional[Any]=None					,   __UpperCamelCase						:						Optional[Any]=True					,   __UpperCamelCase						:						Optional[Any]=False					,   __UpperCamelCase						:						Tuple=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]					,   __UpperCamelCase						:						Optional[int]=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]					,   __UpperCamelCase						:						Tuple=True					,   ):



									'''simple docstring'''






									snake_case__          =						size if size is not None else {"height": 2_0, "width": 2_0}
									snake_case__          =						parent
									snake_case__          =						batch_size
									snake_case__          =						num_channels
									snake_case__          =						image_size
									snake_case__          =						min_resolution
									snake_case__          =						max_resolution
									snake_case__          =						do_resize
									snake_case__          =						size
									snake_case__          =						do_normalize
									snake_case__          =						image_mean
									snake_case__          =						image_std
									snake_case__          =						do_pad
									snake_case__          =						do_convert_rgb






						def       __lowerCAmelCase(   self						:						Any       ):



									'''simple docstring'''






									return {
									    "do_resize": self.do_resize,
									    "size": self.size,
									    "do_normalize": self.do_normalize,
									    "image_mean": self.image_mean,
									    "image_std": self.image_std,
									    "do_convert_rgb": self.do_convert_rgb,
									    "do_pad": self.do_pad,
									}







						def       __lowerCAmelCase(   self						:						Optional[Any]					,   __UpperCamelCase						:						Union[str, Any]=False					,   __UpperCamelCase						:						str=False					,   __UpperCamelCase						:						Optional[int]=False       ):



									'''simple docstring'''






									assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

									if equal_resolution:
												snake_case__          =						[]
												for i in range(self.batch_size       ):
															image_inputs.append(
															    np.random.randint(
															        2_5_5					,   size=(self.num_channels, self.max_resolution, self.max_resolution)					,   dtype=np.uinta       )       )
									else:
												snake_case__          =						[]
												for i in range(self.batch_size       ):
															snake_case__          =						np.random.choice(np.arange(self.min_resolution					,   self.max_resolution       )					,   2       )
															image_inputs.append(np.random.randint(2_5_5					,   size=(self.num_channels, width, height)					,   dtype=np.uinta       )       )

									if not numpify and not torchify:
												# PIL expects the channel dimension as last dimension
												snake_case__          =						[Image.fromarray(np.moveaxis(_a					,   0					,   -1       )       ) for x in image_inputs]

									if torchify:
												snake_case__          =						[torch.from_numpy(_a       ) for x in image_inputs]

									return image_inputs







@require_torch
@require_vision
class __magic_name__(						a_    ,		unittest.TestCase      ):
						UpperCAmelCase_		:					int    =  BlipImageProcessor if is_vision_available() else None






						def       __lowerCAmelCase(   self						:						str       ):



									'''simple docstring'''






									snake_case__          =						BlipImageProcessingTester(self       )






						@property
						def       __lowerCAmelCase(   self						:						str       ):



									'''simple docstring'''






									return self.image_processor_tester.prepare_image_processor_dict()






						def       __lowerCAmelCase(   self						:						Optional[int]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									self.assertTrue(hasattr(_a					,   """do_resize"""       )       )
									self.assertTrue(hasattr(_a					,   """size"""       )       )
									self.assertTrue(hasattr(_a					,   """do_normalize"""       )       )
									self.assertTrue(hasattr(_a					,   """image_mean"""       )       )
									self.assertTrue(hasattr(_a					,   """image_std"""       )       )
									self.assertTrue(hasattr(_a					,   """do_convert_rgb"""       )       )






						def       __lowerCAmelCase(   self						:						int       ):



									'''simple docstring'''






									pass






						def       __lowerCAmelCase(   self						:						Tuple       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									# create random PIL images
									snake_case__          =						self.image_processor_tester.prepare_inputs(equal_resolution=_a       )
									for image in image_inputs:
												self.assertIsInstance(_a					,   Image.Image       )

									# Test not batched input
									snake_case__          =						image_processor(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
									snake_case__          =						image_processor(_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       __lowerCAmelCase(   self						:						Optional[Any]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									# create random numpy tensors
									snake_case__          =						self.image_processor_tester.prepare_inputs(equal_resolution=_a					,   numpify=_a       )
									for image in image_inputs:
												self.assertIsInstance(_a					,   np.ndarray       )

									# Test not batched input
									snake_case__          =						image_processor(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
									snake_case__          =						image_processor(_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       __lowerCAmelCase(   self						:						List[Any]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									# create random PyTorch tensors
									snake_case__          =						self.image_processor_tester.prepare_inputs(equal_resolution=_a					,   torchify=_a       )
									for image in image_inputs:
												self.assertIsInstance(_a					,   torch.Tensor       )

									# Test not batched input
									snake_case__          =						image_processor(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
									snake_case__          =						image_processor(_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"""],
									    )					,   )







@require_torch
@require_vision
class __magic_name__(						a_    ,		unittest.TestCase      ):
						UpperCAmelCase_		:					Union[str, Any]    =  BlipImageProcessor if is_vision_available() else None






						def       __lowerCAmelCase(   self						:						Any       ):



									'''simple docstring'''






									snake_case__          =						BlipImageProcessingTester(self					,   num_channels=4       )
									snake_case__          =						3






						@property
						def       __lowerCAmelCase(   self						:						str       ):



									'''simple docstring'''






									return self.image_processor_tester.prepare_image_processor_dict()






						def       __lowerCAmelCase(   self						:						List[str]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									self.assertTrue(hasattr(_a					,   """do_resize"""       )       )
									self.assertTrue(hasattr(_a					,   """size"""       )       )
									self.assertTrue(hasattr(_a					,   """do_normalize"""       )       )
									self.assertTrue(hasattr(_a					,   """image_mean"""       )       )
									self.assertTrue(hasattr(_a					,   """image_std"""       )       )
									self.assertTrue(hasattr(_a					,   """do_convert_rgb"""       )       )






						def       __lowerCAmelCase(   self						:						Union[str, Any]       ):



									'''simple docstring'''






									pass







						def       __lowerCAmelCase(   self						:						List[str]       ):



									'''simple docstring'''






									snake_case__          =						self.image_processing_class(**self.image_processor_dict       )
									# create random PIL images
									snake_case__          =						self.image_processor_tester.prepare_inputs(equal_resolution=_a       )
									for image in image_inputs:
												self.assertIsInstance(_a					,   Image.Image       )

									# Test not batched input
									snake_case__          =						image_processor(image_inputs[0]					,   return_tensors="""pt"""       ).pixel_values
									self.assertEqual(
									    encoded_images.shape					,   (
									        1,
									        self.expected_encoded_image_num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )					,   )

									# Test batched
									snake_case__          =						image_processor(_a					,   return_tensors="""pt"""       ).pixel_values
									self.assertEqual(
									    encoded_images.shape					,   (
									        self.image_processor_tester.batch_size,
									        self.expected_encoded_image_num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )					,   )



from __future__ import annotations







def 	A (		A__		,		A__		,		A__		,		A__			):

     # Base Case
     if counter == 0 or capacity == 0:
          return 0

     # If weight of the nth item is more than Knapsack of capacity,
     #   then this item cannot be included in the optimal solution,
     # else return the maximum of two cases:
     #   (1) nth item included
     #   (2) not included
     if weights[counter - 1] > capacity:
          return knapsack(A__		,		A__		,		A__		,		counter - 1			)
     else:
          UpperCAmelCase    :					List[str]			=      capacity - weights[counter - 1]
          UpperCAmelCase    :					Tuple			=      values[counter - 1] + knapsack(
              A__		,		A__		,		A__		,		counter - 1			)
          UpperCAmelCase    :					Optional[int]			=      knapsack(A__		,		A__		,		A__		,		counter - 1			)
          return max(A__		,		A__			)


if __name__ == "__main__":
      import doctest

      doctest.testmod()



