"""simple docstring"""




import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


__lowerCamelCase									=	10_00
class      UpperCamelCase__:





						def __init__(							self		,__UpperCAmelCase		,__UpperCAmelCase=1.2		,__UpperCAmelCase="g"		,__UpperCAmelCase=0.5		,__UpperCAmelCase="-"		,__UpperCAmelCase="test_out.jpg"		,__UpperCAmelCase=True		,__UpperCAmelCase=False		,__UpperCAmelCase=None		,__UpperCAmelCase=None		,__UpperCAmelCase=0.7		,)       ->					Tuple:
													if isinstance(__UpperCAmelCase		,torch.Tensor  ):
																				A__						  =				img.numpy().astype('np.uint8'  )
													if isinstance(__UpperCAmelCase		,__UpperCAmelCase  ):
																				A__						  =				img_tensorize(__UpperCAmelCase  )
													assert isinstance(__UpperCAmelCase		,np.ndarray  )

													A__  ,	A__						  =				img.shape[1], img.shape[0]
													A__						  =				mplfigure.Figure(frameon=__UpperCAmelCase  )
													A__						  =				fig.get_dpi()
													A__						  =				(width * scale + 1e-2) / dpi
													A__						  =				(height * scale + 1e-2) / dpi
													fig.set_size_inches(__UpperCAmelCase		,__UpperCAmelCase  )
													A__						  =				fig.add_axes([0.0, 0.0, 1.0, 1.0]  )
													ax.axis('off'  )
													ax.set_xlim(0.0		,__UpperCAmelCase  )
													ax.set_ylim(__UpperCAmelCase  )

													A__						  =				saveas
													A__						  =				rgb
													A__						  =				pynb
													A__						  =				img
													A__						  =				edgecolor
													A__						  =				0.5
													A__						  =				linestyle
													A__						  =				int(np.sqrt(min(__UpperCAmelCase		,__UpperCAmelCase  )  ) * scale // 3  )
													A__						  =				width
													A__						  =				height
													A__						  =				scale
													A__						  =				fig
													A__						  =				ax
													A__						  =				pad
													A__						  =				idaobj
													A__						  =				idaattr
													A__						  =				FigureCanvasAgg(__UpperCAmelCase  )





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase=None  )       ->					str:
													if color is None:
																				A__						  =				self.edgecolor
													((A__)  ,	(A__)  ,	(A__)  ,	(A__))						  =				box
													A__						  =				xa - xa
													A__						  =				ya - ya
													self.ax.add_patch(
													    mpl.patches.Rectangle(
													        (xa, ya)		,__UpperCAmelCase		,__UpperCAmelCase		,fill=__UpperCAmelCase		,edgecolor=__UpperCAmelCase		,linewidth=self.font_size // 3		,alpha=self.alpha		,linestyle=self.linestyle		,)  )





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase=None		,__UpperCAmelCase=None		,__UpperCAmelCase=None		,__UpperCAmelCase=None  )       ->					Optional[Any]:
													if len(boxes.shape  ) > 2:
																				A__						  =				boxes[0]
													if len(obj_ids.shape  ) > 1:
																				A__						  =				obj_ids[0]
													if len(obj_scores.shape  ) > 1:
																				A__						  =				obj_scores[0]
													if len(attr_ids.shape  ) > 1:
																				A__						  =				attr_ids[0]
													if len(attr_scores.shape  ) > 1:
																				A__						  =				attr_scores[0]
													if isinstance(__UpperCAmelCase		,torch.Tensor  ):
																				A__						  =				boxes.numpy()
													if isinstance(__UpperCAmelCase		,__UpperCAmelCase  ):
																				A__						  =				np.array(__UpperCAmelCase  )
													assert isinstance(__UpperCAmelCase		,np.ndarray  )
													A__						  =				np.prod(boxes[:, 2:] - boxes[:, :2]		,axis=1  )
													A__						  =				np.argsort(-areas  ).tolist()
													A__						  =				boxes[sorted_idxs] if boxes is not None else None
													A__						  =				obj_ids[sorted_idxs] if obj_ids is not None else None
													A__						  =				obj_scores[sorted_idxs] if obj_scores is not None else None
													A__						  =				attr_ids[sorted_idxs] if attr_ids is not None else None
													A__						  =				attr_scores[sorted_idxs] if attr_scores is not None else None

													A__						  =				[self._random_color(maximum=1  ) for _ in range(len(__UpperCAmelCase  )  )]
													A__						  =				[assigned_colors[idx] for idx in sorted_idxs]
													if obj_ids is not None:
																				A__						  =				self._create_text_labels_attr(__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )
																				for i in range(len(__UpperCAmelCase  )  ):
																											A__						  =				assigned_colors[i]
																											self.add_box(boxes[i]		,__UpperCAmelCase  )
																											self.draw_labels(labels[i]		,boxes[i]		,__UpperCAmelCase  )





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )       ->					Any:
													A__  ,	A__  ,	A__  ,	A__						  =				box
													A__						  =				(xa, ya)
													A__						  =				(ya - ya) * (xa - xa)
													A__						  =				_SMALL_OBJ * self.scale
													if instance_area < small or ya - ya < 40 * self.scale:
																				if ya >= self.height - 5:
																											A__						  =				(xa, ya)
																				else:
																											A__						  =				(xa, ya)

													A__						  =				(ya - ya) / np.sqrt(self.height * self.width  )
													A__						  =				self._change_color_brightness(__UpperCAmelCase		,brightness_factor=0.7  )
													A__						  =				np.clip((height_ratio - 0.0_2) / 0.0_8 + 1		,1.2		,2  )
													font_size *= 0.7_5 * self.font_size

													self.draw_text(
													    text=__UpperCAmelCase		,position=__UpperCAmelCase		,color=__UpperCAmelCase		,)





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase="g"		,__UpperCAmelCase="left"		,)       ->					Any:
													A__						  =				0
													A__						  =				self.font_size
													A__						  =				np.maximum(list(mplc.to_rgb(__UpperCAmelCase  )  )		,0.2  )
													A__						  =				max(0.8		,np.max(__UpperCAmelCase  )  )
													A__						  =				{
													    'facecolor': 'black',
													    'alpha': self.alpha,
													    'pad': self.pad,
													    'edgecolor': 'none',
													}
													A__  ,	A__						  =				position
													self.ax.text(
													    __UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase		,size=font_size * self.scale		,family='sans-serif'		,bbox=__UpperCAmelCase		,verticalalignment='top'		,horizontalalignment=__UpperCAmelCase		,color=__UpperCAmelCase		,zorder=10		,rotation=__UpperCAmelCase		,)





						def 					snake_case__						(							self		,__UpperCAmelCase=None  )       ->					List[Any]:
													if saveas is None:
																				A__						  =				self.saveas
													if saveas.lower().endswith('.jpg'  ) or saveas.lower().endswith('.png'  ):
																				cva.imwrite(
																				    __UpperCAmelCase		,self._get_buffer()[:, :, ::-1]		,)
													else:
																				self.fig.savefig(__UpperCAmelCase  )





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )       ->					Tuple:
													A__						  =				[self.idaobj[i] for i in classes]
													A__						  =				[self.idaattr[i] for i in attr_classes]
													A__						  =				[
													    f'''{label} {score:.2f} {attr} {attr_score:.2f}'''
													    for label, score, attr, attr_score in zip(__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )
													]
													return labels





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase  )       ->					Dict:
													A__						  =				[self.idaobj[i] for i in classes]
													if scores is not None:
																				if labels is None:
																											A__						  =				['{:.0f}%'.format(s * 1_00  ) for s in scores]
																				else:
																											A__						  =				['{} {:.0f}%'.format(__UpperCAmelCase		,s * 1_00  ) for li, s in zip(__UpperCAmelCase		,__UpperCAmelCase  )]
													return labels





						def 					snake_case__						(							self		,__UpperCAmelCase=2_55  )       ->					List[str]:
													A__						  =				np.random.randint(0		,len(_COLORS  )  )
													A__						  =				_COLORS[idx] * maximum
													if not self.rgb:
																				A__						  =				ret[::-1]
													return ret





						def 					snake_case__						(							self  )       ->					int:
													if not self.pynb:
																				A__  ,	A__						  =				self.canvas.print_to_buffer()
																				if (width, height) != (self.width, self.height):
																											A__						  =				cva.resize(self.img		,(width, height)  )
																				else:
																											A__						  =				self.img
													else:
																				A__						  =				io.BytesIO()  # works for cairo backend
																				self.canvas.print_rgba(__UpperCAmelCase  )
																				A__  ,	A__						  =				self.width, self.height
																				A__						  =				buf.getvalue()
																				A__						  =				self.img

													A__						  =				np.frombuffer(__UpperCAmelCase		,dtype='uint8'  )
													A__						  =				buffer.reshape(__UpperCAmelCase		,__UpperCAmelCase		,4  )
													A__  ,	A__						  =				np.split(__UpperCAmelCase		,[3]		,axis=2  )

													try:
																				import numexpr as ne  # fuse them with numexpr

																				A__						  =				ne.evaluate('img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)'  )
													except ImportError:
																				A__						  =				alpha.astype('float32'  ) / 2_5_5.0
																				A__						  =				img * (1 - alpha) + rgb * alpha

													return visualized_image.astype('uint8'  )





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase  )       ->					Optional[int]:
													assert brightness_factor >= -1.0 and brightness_factor <= 1.0
													A__						  =				mplc.to_rgb(__UpperCAmelCase  )
													A__						  =				colorsys.rgb_to_hls(*mplc.to_rgb(__UpperCAmelCase  )  )
													A__						  =				polygon_color[1] + (brightness_factor * polygon_color[1])
													A__						  =				0.0 if modified_lightness < 0.0 else modified_lightness
													A__						  =				1.0 if modified_lightness > 1.0 else modified_lightness
													A__						  =				colorsys.hls_to_rgb(polygon_color[0]		,__UpperCAmelCase		,polygon_color[2]  )
													return modified_color






__lowerCamelCase									=	(
    np.array(
        [
            0.0_0_0,
            0.4_4_7,
            0.7_4_1,
            0.8_5_0,
            0.3_2_5,
            0.0_9_8,
            0.9_2_9,
            0.6_9_4,
            0.1_2_5,
            0.4_9_4,
            0.1_8_4,
            0.5_5_6,
            0.4_6_6,
            0.6_7_4,
            0.1_8_8,
            0.3_0_1,
            0.7_4_5,
            0.9_3_3,
            0.6_3_5,
            0.0_7_8,
            0.1_8_4,
            0.3_0_0,
            0.3_0_0,
            0.3_0_0,
            0.6_0_0,
            0.6_0_0,
            0.6_0_0,
            1.0_0_0,
            0.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.5_0_0,
            0.0_0_0,
            0.7_4_9,
            0.7_4_9,
            0.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.6_6_7,
            0.0_0_0,
            1.0_0_0,
            0.3_3_3,
            0.3_3_3,
            0.0_0_0,
            0.3_3_3,
            0.6_6_7,
            0.0_0_0,
            0.3_3_3,
            1.0_0_0,
            0.0_0_0,
            0.6_6_7,
            0.3_3_3,
            0.0_0_0,
            0.6_6_7,
            0.6_6_7,
            0.0_0_0,
            0.6_6_7,
            1.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.3_3_3,
            0.0_0_0,
            1.0_0_0,
            0.6_6_7,
            0.0_0_0,
            1.0_0_0,
            1.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.3_3_3,
            0.5_0_0,
            0.0_0_0,
            0.6_6_7,
            0.5_0_0,
            0.0_0_0,
            1.0_0_0,
            0.5_0_0,
            0.3_3_3,
            0.0_0_0,
            0.5_0_0,
            0.3_3_3,
            0.3_3_3,
            0.5_0_0,
            0.3_3_3,
            0.6_6_7,
            0.5_0_0,
            0.3_3_3,
            1.0_0_0,
            0.5_0_0,
            0.6_6_7,
            0.0_0_0,
            0.5_0_0,
            0.6_6_7,
            0.3_3_3,
            0.5_0_0,
            0.6_6_7,
            0.6_6_7,
            0.5_0_0,
            0.6_6_7,
            1.0_0_0,
            0.5_0_0,
            1.0_0_0,
            0.0_0_0,
            0.5_0_0,
            1.0_0_0,
            0.3_3_3,
            0.5_0_0,
            1.0_0_0,
            0.6_6_7,
            0.5_0_0,
            1.0_0_0,
            1.0_0_0,
            0.5_0_0,
            0.0_0_0,
            0.3_3_3,
            1.0_0_0,
            0.0_0_0,
            0.6_6_7,
            1.0_0_0,
            0.0_0_0,
            1.0_0_0,
            1.0_0_0,
            0.3_3_3,
            0.0_0_0,
            1.0_0_0,
            0.3_3_3,
            0.3_3_3,
            1.0_0_0,
            0.3_3_3,
            0.6_6_7,
            1.0_0_0,
            0.3_3_3,
            1.0_0_0,
            1.0_0_0,
            0.6_6_7,
            0.0_0_0,
            1.0_0_0,
            0.6_6_7,
            0.3_3_3,
            1.0_0_0,
            0.6_6_7,
            0.6_6_7,
            1.0_0_0,
            0.6_6_7,
            1.0_0_0,
            1.0_0_0,
            1.0_0_0,
            0.0_0_0,
            1.0_0_0,
            1.0_0_0,
            0.3_3_3,
            1.0_0_0,
            1.0_0_0,
            0.6_6_7,
            1.0_0_0,
            0.3_3_3,
            0.0_0_0,
            0.0_0_0,
            0.5_0_0,
            0.0_0_0,
            0.0_0_0,
            0.6_6_7,
            0.0_0_0,
            0.0_0_0,
            0.8_3_3,
            0.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.1_6_7,
            0.0_0_0,
            0.0_0_0,
            0.3_3_3,
            0.0_0_0,
            0.0_0_0,
            0.5_0_0,
            0.0_0_0,
            0.0_0_0,
            0.6_6_7,
            0.0_0_0,
            0.0_0_0,
            0.8_3_3,
            0.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.1_6_7,
            0.0_0_0,
            0.0_0_0,
            0.3_3_3,
            0.0_0_0,
            0.0_0_0,
            0.5_0_0,
            0.0_0_0,
            0.0_0_0,
            0.6_6_7,
            0.0_0_0,
            0.0_0_0,
            0.8_3_3,
            0.0_0_0,
            0.0_0_0,
            1.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.0_0_0,
            0.1_4_3,
            0.1_4_3,
            0.1_4_3,
            0.8_5_7,
            0.8_5_7,
            0.8_5_7,
            1.0_0_0,
            1.0_0_0,
            1.0_0_0,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)






"""simple docstring"""




import inspect
import unittest

from transformers import is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
				import torch

				from transformers import MODEL_MAPPING, PoolFormerConfig, PoolFormerForImageClassification, PoolFormerModel
				from transformers.models.poolformer.modeling_poolformer import POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
				from PIL import Image

				from transformers import PoolFormerImageProcessor
class      UpperCamelCase__(      __A			):





						def 					snake_case__						(							self  )       ->					int:
													A__						  =				self.config_class(**self.inputs_dict  )
													self.parent.assertTrue(hasattr(__UpperCAmelCase		,'hidden_sizes'  )  )
													self.parent.assertTrue(hasattr(__UpperCAmelCase		,'num_encoder_blocks'  )  )






class      UpperCamelCase__:





						def __init__(							self		,__UpperCAmelCase		,__UpperCAmelCase=13		,__UpperCAmelCase=64		,__UpperCAmelCase=3		,__UpperCAmelCase=4		,__UpperCAmelCase=[2, 2, 2, 2]		,__UpperCAmelCase=[8, 4, 2, 1]		,__UpperCAmelCase=[16, 32, 64, 1_28]		,__UpperCAmelCase=[1, 4, 8, 16]		,__UpperCAmelCase=False		,__UpperCAmelCase=True		,__UpperCAmelCase="gelu"		,__UpperCAmelCase=0.1		,__UpperCAmelCase=0.0_2		,__UpperCAmelCase=3		,__UpperCAmelCase=None		,)       ->					Tuple:
													A__						  =				parent
													A__						  =				batch_size
													A__						  =				image_size
													A__						  =				num_channels
													A__						  =				num_encoder_blocks
													A__						  =				sr_ratios
													A__						  =				depths
													A__						  =				hidden_sizes
													A__						  =				downsampling_rates
													A__						  =				is_training
													A__						  =				use_labels
													A__						  =				hidden_act
													A__						  =				hidden_dropout_prob
													A__						  =				initializer_range
													A__						  =				num_labels
													A__						  =				scope





						def 					snake_case__						(							self  )       ->					Tuple:
													A__						  =				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )

													A__						  =				None
													if self.use_labels:
																				A__						  =				ids_tensor([self.batch_size, self.image_size, self.image_size]		,self.num_labels  )

													A__						  =				PoolFormerConfig(
													    image_size=self.image_size		,num_channels=self.num_channels		,num_encoder_blocks=self.num_encoder_blocks		,depths=self.depths		,hidden_sizes=self.hidden_sizes		,hidden_act=self.hidden_act		,hidden_dropout_prob=self.hidden_dropout_prob		,initializer_range=self.initializer_range		,)

													return config, pixel_values, labels





						def 					snake_case__						(							self		,__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )       ->					Union[str, Any]:
													A__						  =				PoolFormerModel(config=__UpperCAmelCase  )
													model.to(__UpperCAmelCase  )
													model.eval()
													A__						  =				model(__UpperCAmelCase  )
													A__						  =				A__						  =				self.image_size // 3_2.0
													self.parent.assertEqual(
													    result.last_hidden_state.shape		,(self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)  )





						def 					snake_case__						(							self  )       ->					Any:
													A__						  =				self.prepare_config_and_inputs()
													A__  ,	A__  ,	A__						  =				config_and_inputs
													A__						  =				{'pixel_values': pixel_values}
													return config, inputs_dict






@require_torch
class      UpperCamelCase__(      __A		,    __A		,    unittest.TestCase			):
						lowerCAmelCase__	:    Optional[int]    				=		(PoolFormerModel, PoolFormerForImageClassification) if is_torch_available() else ()
						lowerCAmelCase__	:    Optional[Any]    				=		(
						    {'feature-extraction': PoolFormerModel, 'image-classification': PoolFormerForImageClassification}
						    if is_torch_available()
						    else {}
						)

						lowerCAmelCase__	:    Any    				=		False
						lowerCAmelCase__	:    str    				=		False
						lowerCAmelCase__	:    Any    				=		False
						lowerCAmelCase__	:    str    				=		False
						lowerCAmelCase__	:    Optional[int]    				=		False





						def 					snake_case__						(							self  )       ->					Any:
													A__						  =				PoolFormerModelTester(self  )
													A__						  =				PoolFormerConfigTester(self		,config_class=__UpperCAmelCase  )





						def 					snake_case__						(							self  )       ->					int:
													self.config_tester.run_common_tests()





						def 					snake_case__						(							self  )       ->					Tuple:
													A__						  =				self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*__UpperCAmelCase  )





						@unittest.skip('PoolFormer does not use inputs_embeds'  )
						def 					snake_case__						(							self  )       ->					int:
													pass





						@unittest.skip('PoolFormer does not have get_input_embeddings method and get_output_embeddings methods'  )
						def 					snake_case__						(							self  )       ->					List[str]:
													pass





						def 					snake_case__						(							self  )       ->					List[Any]:
													def check_hidden_states_output(__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  ):
																				A__						  =				model_class(__UpperCAmelCase  )
																				model.to(__UpperCAmelCase  )
																				model.eval()

																				with torch.no_grad():
																											A__						  =				model(**self._prepare_for_class(__UpperCAmelCase		,__UpperCAmelCase  )  )

																				A__						  =				outputs.hidden_states

																				A__						  =				self.model_tester.num_encoder_blocks
																				self.assertEqual(len(__UpperCAmelCase  )		,__UpperCAmelCase  )

																				# verify the first hidden states (first block)
																				self.assertListEqual(
																				    list(hidden_states[0].shape[-3:]  )		,[
																				        self.model_tester.hidden_sizes[0],
																				        self.model_tester.image_size // 4,
																				        self.model_tester.image_size // 4,
																				    ]		,)

													A__  ,	A__						  =				self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																				A__						  =				True
																				check_hidden_states_output(__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )

																				# check that output_hidden_states also work using config
																				del inputs_dict["output_hidden_states"]
																				A__						  =				True

																				check_hidden_states_output(__UpperCAmelCase		,__UpperCAmelCase		,__UpperCAmelCase  )





						def 					snake_case__						(							self  )       ->					Union[str, Any]:
													if not self.model_tester.is_training:
																				return

													A__  ,	A__						  =				self.model_tester.prepare_config_and_inputs_for_common()
													A__						  =				True

													for model_class in self.all_model_classes:
																				if model_class in get_values(__UpperCAmelCase  ):
																											continue
																				A__						  =				model_class(__UpperCAmelCase  )
																				model.to(__UpperCAmelCase  )
																				model.train()
																				A__						  =				self._prepare_for_class(__UpperCAmelCase		,__UpperCAmelCase		,return_labels=__UpperCAmelCase  )
																				A__						  =				model(**__UpperCAmelCase  ).loss
																				loss.backward()





						def 					snake_case__						(							self  )       ->					Union[str, Any]:
													A__  ,	A__						  =				self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																				A__						  =				model_class(__UpperCAmelCase  )
																				A__						  =				inspect.signature(model.forward  )
																				# signature.parameters is an OrderedDict => so arg_names order is deterministic
																				A__						  =				[*signature.parameters.keys()]

																				A__						  =				['pixel_values']
																				self.assertListEqual(arg_names[:1]		,__UpperCAmelCase  )





						@slow
						def 					snake_case__						(							self  )       ->					Union[str, Any]:
													for model_name in POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																				A__						  =				PoolFormerModel.from_pretrained(__UpperCAmelCase  )
																				self.assertIsNotNone(__UpperCAmelCase  )






def 	UpperCAmelCase       (						):






							"""simple docstring"""





							A__						  =				Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'					)
							return image


@require_torch
class      UpperCamelCase__(      unittest.TestCase			):





						@slow
						def 					snake_case__						(							self  )       ->					Union[str, Any]:
													A__						  =				PoolFormerImageProcessor()
													A__						  =				PoolFormerForImageClassification.from_pretrained('sail/poolformer_s12'  ).to(__UpperCAmelCase  )

													A__						  =				image_processor(images=prepare_img()		,return_tensors='pt'  ).to(__UpperCAmelCase  )

													# forward pass
													with torch.no_grad():
																				A__						  =				model(**__UpperCAmelCase  )

													# verify the logits
													A__						  =				torch.Size((1, 10_00)  )
													self.assertEqual(outputs.logits.shape		,__UpperCAmelCase  )

													A__						  =				torch.tensor([-0.6_1_1_3, 0.1_6_8_5, -0.0_4_9_2]  ).to(__UpperCAmelCase  )
													self.assertTrue(torch.allclose(outputs.logits[0, :3]		,__UpperCAmelCase		,atol=1e-4  )  )





