


"""simple docstring"""


import unittest

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device


if is_torch_available():
	import torch

	from transformers import AutoModelForImageClassification

if is_vision_available():
	from transformers import AutoImageProcessor
@require_torch
@require_vision
class   _UpperCamelCase  (   unittest.TestCase		):
							'''simple docstring'''







							@slow
							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			AutoImageProcessor.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"	)
										__lowerCAmelCase				    =			AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"	)
										model.to(__a	)

										from datasets import load_dataset

										__lowerCAmelCase				    =			load_dataset("nielsr/rvlcdip-demo"	)

										__lowerCAmelCase				    =			dataset["train"][0]["image"].convert("RGB"	)

										__lowerCAmelCase				    =			image_processor(__a    ,   return_tensors="pt"	).to(__a	)

										# forward pass
										with torch.no_grad():
													__lowerCAmelCase				    =			model(**__a	)
													__lowerCAmelCase				    =			outputs.logits

										__lowerCAmelCase				    =			torch.Size((1, 16)	)
										self.assertEqual(logits.shape    ,   __a	)

										__lowerCAmelCase				    =			torch.tensor(
										    [-0.4_1_5_8, -0.4_0_9_2, -0.4_3_4_7]    ,   device=__a    ,   dtype=torch.float    ,   )
										self.assertTrue(torch.allclose(logits[0, :3]    ,   __a    ,   atol=1e-4	)	)








"""simple docstring"""


from __future__ import annotations


def _lowerCamelCase	(		_UpperCamelCase = 4      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			abs(_UpperCamelCase      ) or 4
			return [[1 + x + y * row_size for x in range(_UpperCamelCase      )] for y in range(_UpperCamelCase      )]


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			return reverse_row(transpose(_UpperCamelCase      )      )
			# OR.. transpose(reverse_column(matrix))


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			return reverse_row(reverse_column(_UpperCamelCase      )      )
			# OR.. reverse_column(reverse_row(matrix))


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			return reverse_column(transpose(_UpperCamelCase      )      )
			# OR.. transpose(reverse_row(matrix))


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			[list(_UpperCamelCase      ) for x in zip(*_UpperCamelCase      )]
			return matrix


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			matrix[::-1]
			return matrix


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			[x[::-1] for x in matrix]
			return matrix


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			for i in matrix:
						print(*_UpperCamelCase      )


if __name__ == "__main__":
	A     :   Dict			    =			make_matrix()
	print("\norigin:\n")
	print_matrix(matrix)
	print("\nrotate 90 counterclockwise:\n")
	print_matrix(rotate_aa(matrix))

	A     :   List[str]			    =			make_matrix()
	print("\norigin:\n")
	print_matrix(matrix)
	print("\nrotate 180:\n")
	print_matrix(rotate_aaa(matrix))

	A     :   str			    =			make_matrix()
	print("\norigin:\n")
	print_matrix(matrix)
	print("\nrotate 270 counterclockwise:\n")
	print_matrix(rotate_aaa(matrix))




