





import copy
import unittest

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

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


if is_torch_available():
					import torch

					from transformers import (
					    MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
					    MODEL_FOR_QUESTION_ANSWERING_MAPPING,
					    MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
					    MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
					    LayoutLMvaConfig,
					    LayoutLMvaForQuestionAnswering,
					    LayoutLMvaForSequenceClassification,
					    LayoutLMvaForTokenClassification,
					    LayoutLMvaModel,
					)
					from transformers.models.layoutlmva.modeling_layoutlmva import LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
					from PIL import Image

					from transformers import LayoutLMvaImageProcessor


class     A     :
			'''simple docstring'''




			def __init__(     self  :       Any				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Union[str, Any]=2				,      __lowerCAmelCase  :       Any=3				,      __lowerCAmelCase  :       Dict=4				,      __lowerCAmelCase  :       Dict=2				,      __lowerCAmelCase  :       List[Any]=7				,      __lowerCAmelCase  :       Union[str, Any]=True				,      __lowerCAmelCase  :       List[str]=True				,      __lowerCAmelCase  :       int=True				,      __lowerCAmelCase  :       List[Any]=True				,      __lowerCAmelCase  :       int=99				,      __lowerCAmelCase  :       Dict=36				,      __lowerCAmelCase  :       Tuple=3				,      __lowerCAmelCase  :       Dict=4				,      __lowerCAmelCase  :       Dict=37				,      __lowerCAmelCase  :       Optional[Any]="gelu"				,      __lowerCAmelCase  :       Dict=0.1				,      __lowerCAmelCase  :       Union[str, Any]=0.1				,      __lowerCAmelCase  :       Optional[int]=5_12				,      __lowerCAmelCase  :       List[Any]=16				,      __lowerCAmelCase  :       str=2				,      __lowerCAmelCase  :       Union[str, Any]=0.0_2				,      __lowerCAmelCase  :       Optional[int]=6				,      __lowerCAmelCase  :       Union[str, Any]=6				,      __lowerCAmelCase  :       Optional[int]=3				,      __lowerCAmelCase  :       Union[str, Any]=4				,      __lowerCAmelCase  :       List[Any]=None				,      __lowerCAmelCase  :       List[Any]=10_00				,      )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  parent
					A__     =  batch_size
					A__     =  num_channels
					A__     =  image_size
					A__     =  patch_size
					A__     =  text_seq_length
					A__     =  is_training
					A__     =  use_input_mask
					A__     =  use_token_type_ids
					A__     =  use_labels
					A__     =  vocab_size
					A__     =  hidden_size
					A__     =  num_hidden_layers
					A__     =  num_attention_heads
					A__     =  intermediate_size
					A__     =  hidden_act
					A__     =  hidden_dropout_prob
					A__     =  attention_probs_dropout_prob
					A__     =  max_position_embeddings
					A__     =  type_vocab_size
					A__     =  type_sequence_label_size
					A__     =  initializer_range
					A__     =  coordinate_size
					A__     =  shape_size
					A__     =  num_labels
					A__     =  num_choices
					A__     =  scope
					A__     =  range_bbox

					# LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
					A__     =  text_seq_length
					A__     =  (image_size // patch_size) ** 2 + 1
					A__     =  self.text_seq_length + self.image_seq_length






			def   a_			(     self  :       str  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  ids_tensor([self.batch_size, self.text_seq_length]				,      self.vocab_size  )

					A__     =  ids_tensor([self.batch_size, self.text_seq_length, 4]				,      self.range_bbox  )
					# Ensure that bbox is legal
					for i in range(bbox.shape[0]  ):
							for j in range(bbox.shape[1]  ):
									if bbox[i, j, 3] < bbox[i, j, 1]:
											A__     =  bbox[i, j, 3]
											A__     =  bbox[i, j, 1]
											A__     =  t
									if bbox[i, j, 2] < bbox[i, j, 0]:
											A__     =  bbox[i, j, 2]
											A__     =  bbox[i, j, 0]
											A__     =  t

					A__     =  floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )

					A__     =  None
					if self.use_input_mask:
							A__     =  random_attention_mask([self.batch_size, self.text_seq_length]  )

					A__     =  None
					if self.use_token_type_ids:
							A__     =  ids_tensor([self.batch_size, self.text_seq_length]				,      self.type_vocab_size  )

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

					A__     =  LayoutLMvaConfig(
					    vocab_size=self.vocab_size				,      hidden_size=self.hidden_size				,      num_hidden_layers=self.num_hidden_layers				,      num_attention_heads=self.num_attention_heads				,      intermediate_size=self.intermediate_size				,      hidden_act=self.hidden_act				,      hidden_dropout_prob=self.hidden_dropout_prob				,      attention_probs_dropout_prob=self.attention_probs_dropout_prob				,      max_position_embeddings=self.max_position_embeddings				,      type_vocab_size=self.type_vocab_size				,      initializer_range=self.initializer_range				,      coordinate_size=self.coordinate_size				,      shape_size=self.shape_size				,      input_size=self.image_size				,      patch_size=self.patch_size				,      )

					return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels






			def   a_			(     self  :       Dict				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       List[str]				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       Union[str, Any]				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       List[str]				,      __lowerCAmelCase  :       Any  )      ->      int:







					"""simple docstring"""






					A__     =  LayoutLMvaModel(config=lowerCamelCase_  )
					model.to(lowerCamelCase_  )
					model.eval()

					# text + image
					A__     =  model(lowerCamelCase_				,      pixel_values=lowerCamelCase_  )
					A__     =  model(
					    lowerCamelCase_				,      bbox=lowerCamelCase_				,      pixel_values=lowerCamelCase_				,      attention_mask=lowerCamelCase_				,      token_type_ids=lowerCamelCase_  )
					A__     =  model(lowerCamelCase_				,      bbox=lowerCamelCase_				,      pixel_values=lowerCamelCase_				,      token_type_ids=lowerCamelCase_  )
					A__     =  model(lowerCamelCase_				,      bbox=lowerCamelCase_				,      pixel_values=lowerCamelCase_  )

					self.parent.assertEqual(result.last_hidden_state.shape				,      (self.batch_size, self.seq_length, self.hidden_size)  )

					# text only
					A__     =  model(lowerCamelCase_  )
					self.parent.assertEqual(
					    result.last_hidden_state.shape				,      (self.batch_size, self.text_seq_length, self.hidden_size)  )

					# image only
					A__     =  model(pixel_values=lowerCamelCase_  )
					self.parent.assertEqual(
					    result.last_hidden_state.shape				,      (self.batch_size, self.image_seq_length, self.hidden_size)  )






			def   a_			(     self  :       Any				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       Optional[Any]				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Union[str, Any]				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       Optional[Any]				,      __lowerCAmelCase  :       str  )      ->      Optional[Any]:







					"""simple docstring"""






					A__     =  self.num_labels
					A__     =  LayoutLMvaForSequenceClassification(lowerCamelCase_  )
					model.to(lowerCamelCase_  )
					model.eval()
					A__     =  model(
					    lowerCamelCase_				,      bbox=lowerCamelCase_				,      pixel_values=lowerCamelCase_				,      attention_mask=lowerCamelCase_				,      token_type_ids=lowerCamelCase_				,      labels=lowerCamelCase_				,      )
					self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.num_labels)  )






			def   a_			(     self  :       int				,      __lowerCAmelCase  :       Dict				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       Optional[Any]				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       str				,      __lowerCAmelCase  :       str  )      ->      Optional[int]:







					"""simple docstring"""






					A__     =  self.num_labels
					A__     =  LayoutLMvaForTokenClassification(config=lowerCamelCase_  )
					model.to(lowerCamelCase_  )
					model.eval()
					A__     =  model(
					    lowerCamelCase_				,      bbox=lowerCamelCase_				,      pixel_values=lowerCamelCase_				,      attention_mask=lowerCamelCase_				,      token_type_ids=lowerCamelCase_				,      labels=lowerCamelCase_				,      )
					self.parent.assertEqual(result.logits.shape				,      (self.batch_size, self.text_seq_length, self.num_labels)  )






			def   a_			(     self  :       Optional[Any]				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Union[str, Any]				,      __lowerCAmelCase  :       Dict				,      __lowerCAmelCase  :       Tuple				,      __lowerCAmelCase  :       int				,      __lowerCAmelCase  :       Optional[Any]  )      ->      Union[str, Any]:







					"""simple docstring"""






					A__     =  LayoutLMvaForQuestionAnswering(config=lowerCamelCase_  )
					model.to(lowerCamelCase_  )
					model.eval()
					A__     =  model(
					    lowerCamelCase_				,      bbox=lowerCamelCase_				,      pixel_values=lowerCamelCase_				,      attention_mask=lowerCamelCase_				,      token_type_ids=lowerCamelCase_				,      start_positions=lowerCamelCase_				,      end_positions=lowerCamelCase_				,      )
					self.parent.assertEqual(result.start_logits.shape				,      (self.batch_size, self.seq_length)  )
					self.parent.assertEqual(result.end_logits.shape				,      (self.batch_size, self.seq_length)  )







			def   a_			(     self  :       int  )      ->      str:







					"""simple docstring"""






					A__     =  self.prepare_config_and_inputs()
					(
					    A__				
					)     =  config_and_inputs
					A__     =  {
					    'input_ids': input_ids,
					    'bbox': bbox,
					    'pixel_values': pixel_values,
					    'token_type_ids': token_type_ids,
					    'attention_mask': input_mask,
					}
					return config, inputs_dict


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




			__lowerCamelCase      :			Dict							     =       False
			__lowerCamelCase      :			List[Any]							     =       False
			__lowerCamelCase      :			Dict							     =       False

			__lowerCamelCase      :			List[Any]							     =       (
			    (
			        LayoutLMvaModel,
			        LayoutLMvaForSequenceClassification,
			        LayoutLMvaForTokenClassification,
			        LayoutLMvaForQuestionAnswering,
			    )
			    if is_torch_available()
			    else ()
			)
			__lowerCamelCase      :			List[Any]							     =       (
			    {'''document-question-answering''': LayoutLMvaForQuestionAnswering, '''feature-extraction''': LayoutLMvaModel}
			    if is_torch_available()
			    else {}
			)






			def   a_			(     self  :       Dict				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Any				,      __lowerCAmelCase  :       Optional[int]				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       Dict  )      ->      List[Any]:







					"""simple docstring"""






					return True






			def   a_			(     self  :       Tuple  )      ->      List[Any]:







					"""simple docstring"""






					A__     =  LayoutLMvaModelTester(self  )
					A__     =  ConfigTester(self				,      config_class=lowerCamelCase_				,      hidden_size=37  )






			def   a_			(     self  :       int				,      __lowerCAmelCase  :       List[str]				,      __lowerCAmelCase  :       List[Any]				,      __lowerCAmelCase  :       int=False  )      ->      Optional[Any]:







					"""simple docstring"""






					A__     =  copy.deepcopy(lowerCamelCase_  )
					if model_class in get_values(lowerCamelCase_  ):
							A__     =  {
							    k: v.unsqueeze(1  ).expand(-1				,      self.model_tester.num_choices				,      -1  ).contiguous()
							    if isinstance(lowerCamelCase_				,      torch.Tensor  ) and v.ndim > 1
							    else v
							    for k, v in inputs_dict.items()
							}
					if return_labels:
							if model_class in get_values(lowerCamelCase_  ):
									A__     =  torch.ones(self.model_tester.batch_size				,      dtype=torch.long				,      device=lowerCamelCase_  )
							elif model_class in get_values(lowerCamelCase_  ):
									A__     =  torch.zeros(
									    self.model_tester.batch_size				,      dtype=torch.long				,      device=lowerCamelCase_  )
									A__     =  torch.zeros(
									    self.model_tester.batch_size				,      dtype=torch.long				,      device=lowerCamelCase_  )
							elif model_class in [
							    *get_values(lowerCamelCase_  ),
							]:
									A__     =  torch.zeros(
									    self.model_tester.batch_size				,      dtype=torch.long				,      device=lowerCamelCase_  )
							elif model_class in [
							    *get_values(lowerCamelCase_  ),
							]:
									A__     =  torch.zeros(
									    (self.model_tester.batch_size, self.model_tester.text_seq_length)				,      dtype=torch.long				,      device=lowerCamelCase_				,      )

					return inputs_dict






			def   a_			(     self  :       Union[str, Any]  )      ->      Tuple:







					"""simple docstring"""






					self.config_tester.run_common_tests()






			def   a_			(     self  :       Tuple  )      ->      Any:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*lowerCamelCase_  )






			def   a_			(     self  :       List[str]  )      ->      Tuple:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					for type in ["absolute", "relative_key", "relative_key_query"]:
							A__     =  type
							self.model_tester.create_and_check_model(*lowerCamelCase_  )






			def   a_			(     self  :       str  )      ->      Optional[Any]:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase_  )






			def   a_			(     self  :       Any  )      ->      Optional[Any]:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_token_classification(*lowerCamelCase_  )






			def   a_			(     self  :       Union[str, Any]  )      ->      Union[str, Any]:







					"""simple docstring"""






					A__     =  self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_question_answering(*lowerCamelCase_  )







			@slow
			def   a_			(     self  :       Tuple  )      ->      List[Any]:







					"""simple docstring"""






					for model_name in LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							A__     =  LayoutLMvaModel.from_pretrained(lowerCamelCase_  )
							self.assertIsNotNone(lowerCamelCase_  )







def   __lowerCamelCase   (				)						->							Optional[Any]:






		"""simple docstring"""

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






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




			@cached_property
			def   a_			(     self  :       Tuple  )      ->      List[Any]:







					"""simple docstring"""






					return LayoutLMvaImageProcessor(apply_ocr=lowerCamelCase_  ) if is_vision_available() else None







			@slow
			def   a_			(     self  :       Dict  )      ->      Any:







					"""simple docstring"""






					A__     =  LayoutLMvaModel.from_pretrained("""microsoft/layoutlmv3-base"""  ).to(lowerCamelCase_  )

					A__     =  self.default_image_processor
					A__     =  prepare_img()
					A__     =  image_processor(images=lowerCamelCase_				,      return_tensors="""pt"""  ).pixel_values.to(lowerCamelCase_  )

					A__     =  torch.tensor([[1, 2]]  )
					A__     =  torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]]  ).unsqueeze(0  )

					# forward pass
					A__     =  model(
					    input_ids=input_ids.to(lowerCamelCase_  )				,      bbox=bbox.to(lowerCamelCase_  )				,      pixel_values=pixel_values.to(lowerCamelCase_  )				,      )

					# verify the logits
					A__     =  torch.Size((1, 1_99, 7_68)  )
					self.assertEqual(outputs.last_hidden_state.shape				,      lowerCamelCase_  )

					A__     =  torch.tensor(
					    [[-0.0_5_2_9, 0.3_6_1_8, 0.1_6_3_2], [-0.1_5_8_7, -0.1_6_6_7, -0.0_4_0_0], [-0.1_5_5_7, -0.1_6_7_1, -0.0_5_0_5]]  ).to(lowerCamelCase_  )

					self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]				,      lowerCamelCase_				,      atol=1e-4  )  )










import gc
import inspect
import unittest

import torch
from parameterized import parameterized

from diffusers import PriorTransformer
from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from .test_modeling_common import ModelTesterMixin


enable_full_determinism()


class       __lowerCAmelCase					(       _UpperCamelCase   ,    unittest.TestCase      ):


	'''simple docstring'''





	_A													=				PriorTransformer
	_A													=				"hidden_states"

	@property
	def    snake_case__(						self:						Union[str, Any]			):
			lowercase__					:      List[Any]      =		4
			lowercase__					:      Optional[int]      =		8
			lowercase__					:      List[str]      =		7

			lowercase__					:      Optional[Any]      =		floats_tensor((batch_size, embedding_dim)			).to(lowerCamelCase_			)

			lowercase__					:      Union[str, Any]      =		floats_tensor((batch_size, embedding_dim)			).to(lowerCamelCase_			)
			lowercase__					:      Any      =		floats_tensor((batch_size, num_embeddings, embedding_dim)			).to(lowerCamelCase_			)

			return {
			    "hidden_states": hidden_states,
			    "timestep": 2,
			    "proj_embedding": proj_embedding,
			    "encoder_hidden_states": encoder_hidden_states,
			}

	def    snake_case__(						self:						int,					lowerCamelCase_:						Dict=0			):
			torch.manual_seed(lowerCamelCase_			)
			lowercase__					:      Tuple      =		4
			lowercase__					:      List[Any]      =		8
			lowercase__					:      List[str]      =		7

			lowercase__					:      Union[str, Any]      =		torch.randn((batch_size, embedding_dim)			).to(lowerCamelCase_			)

			lowercase__					:      Optional[int]      =		torch.randn((batch_size, embedding_dim)			).to(lowerCamelCase_			)
			lowercase__					:      List[str]      =		torch.randn((batch_size, num_embeddings, embedding_dim)			).to(lowerCamelCase_			)

			return {
			    "hidden_states": hidden_states,
			    "timestep": 2,
			    "proj_embedding": proj_embedding,
			    "encoder_hidden_states": encoder_hidden_states,
			}

	@property
	def    snake_case__(						self:						str			):
			return (4, 8)

	@property
	def    snake_case__(						self:						List[str]			):
			return (4, 8)

	def    snake_case__(						self:						Dict			):
			lowercase__					:      int      =		{
			    'num_attention_heads': 2,
			    'attention_head_dim': 4,
			    'num_layers': 2,
			    'embedding_dim': 8,
			    'num_embeddings': 7,
			    'additional_embeddings': 4,
			}
			lowercase__					:      Optional[Any]      =		self.dummy_input
			return init_dict, inputs_dict

	def    snake_case__(						self:						int			):
			lowercase__   ,				lowercase__					:      Dict      =		PriorTransformer.from_pretrained(
			    'hf-internal-testing/prior-dummy',					output_loading_info=lowerCamelCase_			)
			self.assertIsNotNone(lowerCamelCase_			)
			self.assertEqual(len(loading_info['missing_keys']			),					0			)

			model.to(lowerCamelCase_			)
			lowercase__					:      Tuple      =		model(**self.dummy_input			)[0]

			assert hidden_states is not None, "Make sure output is not None"

	def    snake_case__(						self:						str			):
			lowercase__   ,				lowercase__					:      List[Any]      =		self.prepare_init_args_and_inputs_for_common()

			lowercase__					:      Optional[int]      =		self.model_class(**lowerCamelCase_			)
			lowercase__					:      int      =		inspect.signature(model.forward			)
			# signature.parameters is an OrderedDict => so arg_names order is deterministic
			lowercase__					:      Dict      =		[*signature.parameters.keys()]

			lowercase__					:      List[str]      =		['hidden_states', 'timestep']
			self.assertListEqual(arg_names[:2],					lowerCamelCase_			)





	def    snake_case__(						self:						Union[str, Any]			):
			lowercase__					:      str      =		PriorTransformer.from_pretrained('hf-internal-testing/prior-dummy'			)
			lowercase__					:      Optional[int]      =		model.to(lowerCamelCase_			)

			if hasattr(lowerCamelCase_,					'set_default_attn_processor'			):
					model.set_default_attn_processor()

			lowercase__					:      List[str]      =		self.get_dummy_seed_input()

			with torch.no_grad():
					lowercase__					:      str      =		model(**lowerCamelCase_			)[0]

			lowercase__					:      int      =		output[0, :5].flatten().cpu()
			print(lowerCamelCase_			)

			# Since the VAE Gaussian prior's generator is seeded on the appropriate device,
			# the expected output slices are not the same for CPU and GPU.
			lowercase__					:      List[str]      =		torch.tensor([-1.3_4_3_6, -0.2_8_7_0, 0.7_5_3_8, 0.4_3_6_8, -0.0_2_3_9]			)
			self.assertTrue(torch_all_close(lowerCamelCase_,					lowerCamelCase_,					rtol=1E-2			)			)


@slow
class       __lowerCAmelCase					(       unittest.TestCase      ):


	'''simple docstring'''





	def    snake_case__(						self:						Tuple,					lowerCamelCase_:						Union[str, Any]=1,					lowerCamelCase_:						Tuple=768,					lowerCamelCase_:						Dict=77,					lowerCamelCase_:						Union[str, Any]=0			):
			torch.manual_seed(lowerCamelCase_			)
			lowercase__					:      Dict      =		batch_size
			lowercase__					:      Dict      =		embedding_dim
			lowercase__					:      Dict      =		num_embeddings

			lowercase__					:      int      =		torch.randn((batch_size, embedding_dim)			).to(lowerCamelCase_			)

			lowercase__					:      str      =		torch.randn((batch_size, embedding_dim)			).to(lowerCamelCase_			)
			lowercase__					:      List[str]      =		torch.randn((batch_size, num_embeddings, embedding_dim)			).to(lowerCamelCase_			)

			return {
			    "hidden_states": hidden_states,
			    "timestep": 2,
			    "proj_embedding": proj_embedding,
			    "encoder_hidden_states": encoder_hidden_states,
			}

	def    snake_case__(						self:						str			):
			# clean up the VRAM after each test
			super().tearDown()
			gc.collect()
			torch.cuda.empty_cache()





	@parameterized.expand(
	    [
	        # fmt: off
	        [13, [-0.5_8_6_1,  0.1_2_8_3, -0.0_9_3_1,  0.0_8_8_2,  0.4_4_7_6,  0.1_3_2_9, -0.0_4_9_8,  0.0_6_4_0]],
	        [37, [-0.4_9_1_3,  0.0_1_1_0, -0.0_4_8_3,  0.0_5_4_1,  0.4_9_5_4, -0.0_1_7_0,  0.0_3_5_4,  0.1_6_5_1]],
	        # fmt: on
	    ]			)
	def    snake_case__(						self:						Optional[Any],					lowerCamelCase_:						List[str],					lowerCamelCase_:						str			):
			lowercase__					:      List[Any]      =		PriorTransformer.from_pretrained('kandinsky-community/kandinsky-2-1-prior',					subfolder='prior'			)
			model.to(lowerCamelCase_			)
			lowercase__					:      Optional[int]      =		self.get_dummy_seed_input(seed=lowerCamelCase_			)

			with torch.no_grad():
					lowercase__					:      List[str]      =		model(**lowerCamelCase_			)[0]

			assert list(sample.shape			) == [1, 768]

			lowercase__					:      Union[str, Any]      =		sample[0, :8].flatten().cpu()
			print(lowerCamelCase_			)
			lowercase__					:      Optional[Any]      =		torch.tensor(lowerCamelCase_			)

			assert torch_all_close(lowerCamelCase_,					lowerCamelCase_,					atol=1E-3			)


