import tempfile
import unittest

import transformers
from transformers import XGLMConfig, XGLMTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, require_sentencepiece, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
	import jax
	import jax.numpy as jnp
	import numpy as np

	from transformers.modeling_flax_pytorch_utils import (
	    convert_pytorch_state_dict_to_flax,
	    load_flax_weights_in_pytorch_model,
	)
	from transformers.models.xglm.modeling_flax_xglm import FlaxXGLMForCausalLM, FlaxXGLMModel


if is_torch_available():
	import torch




@require_flax
class 					_snake_case						:
					def __init__(  self:				Optional[Any]	,  __lowerCamelCase:				Optional[int]	,  __lowerCamelCase:				Optional[int]=14	,  __lowerCamelCase:				Tuple=7	,  __lowerCamelCase:				List[str]=True	,  __lowerCamelCase:				List[Any]=True	,  __lowerCamelCase:				Optional[int]=True	,  __lowerCamelCase:				List[str]=99	,  __lowerCamelCase:				Dict=32	,  __lowerCamelCase:				Optional[int]=5	,  __lowerCamelCase:				Union[str, Any]=4	,  __lowerCamelCase:				Union[str, Any]=37	,  __lowerCamelCase:				List[str]="gelu"	,  __lowerCamelCase:				str=0.1	,  __lowerCamelCase:				str=0.1	,  __lowerCamelCase:				List[str]=5_12	,  __lowerCamelCase:				Tuple=0.02	,  __lowerCamelCase:				Union[str, Any]=None	,  )    ->				Any:
												__UpperCAmelCase						:			Optional[int]         =   parent
												__UpperCAmelCase						:			List[Any]         =   batch_size
												__UpperCAmelCase						:			Optional[Any]         =   seq_length
												__UpperCAmelCase						:			Union[str, Any]         =   is_training
												__UpperCAmelCase						:			Optional[Any]         =   use_input_mask
												__UpperCAmelCase						:			Optional[Any]         =   use_labels
												__UpperCAmelCase						:			List[str]         =   vocab_size
												__UpperCAmelCase						:			List[str]         =   d_model
												__UpperCAmelCase						:			Any         =   num_hidden_layers
												__UpperCAmelCase						:			Optional[int]         =   num_attention_heads
												__UpperCAmelCase						:			List[Any]         =   ffn_dim
												__UpperCAmelCase						:			int         =   activation_function
												__UpperCAmelCase						:			Tuple         =   activation_dropout
												__UpperCAmelCase						:			Tuple         =   attention_dropout
												__UpperCAmelCase						:			List[str]         =   max_position_embeddings
												__UpperCAmelCase						:			Dict         =   initializer_range
												__UpperCAmelCase						:			Optional[Any]         =   None
												__UpperCAmelCase						:			str         =   0
												__UpperCAmelCase						:			List[Any]         =   2
												__UpperCAmelCase						:			str         =   1
					def    _lowerCamelCase (  self:				Union[str, Any]     )    ->				Optional[Any]:
												__UpperCAmelCase						:			Optional[int]         =   np.clip(ids_tensor([self.batch_size, self.seq_length]	,  self.vocab_size     )	,  3	,  self.vocab_size     )

												__UpperCAmelCase						:			Tuple         =   None
												if self.use_input_mask:
																			__UpperCAmelCase						:			int         =   random_attention_mask([self.batch_size, self.seq_length]     )

												__UpperCAmelCase						:			int         =   XGLMConfig(
												    vocab_size=self.vocab_size	,  d_model=self.hidden_size	,  num_layers=self.num_hidden_layers	,  attention_heads=self.num_attention_heads	,  ffn_dim=self.ffn_dim	,  activation_function=self.activation_function	,  activation_dropout=self.activation_dropout	,  attention_dropout=self.attention_dropout	,  max_position_embeddings=self.max_position_embeddings	,  initializer_range=self.initializer_range	,  use_cache=__lowerCamelCase	,  bos_token_id=self.bos_token_id	,  eos_token_id=self.eos_token_id	,  pad_token_id=self.pad_token_id	,  )

												return (config, input_ids, input_mask)
					def    _lowerCamelCase (  self:				str     )    ->				Dict:
												__UpperCAmelCase						:			Any         =   self.prepare_config_and_inputs()
												__UpperCAmelCase    ,	__UpperCAmelCase    ,	__UpperCAmelCase						:			List[str]         =   config_and_inputs
												__UpperCAmelCase						:			Optional[Any]         =   {"input_ids": input_ids, "attention_mask": attention_mask}
												return config, inputs_dict
					def    _lowerCamelCase (  self:				Optional[int]     )    ->				Dict:
												__UpperCAmelCase    ,	__UpperCAmelCase    ,	__UpperCAmelCase						:			Optional[int]         =   self.prepare_config_and_inputs()

												__UpperCAmelCase						:			Optional[int]         =   floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
												__UpperCAmelCase						:			Any         =   ids_tensor([self.batch_size, self.seq_length]	,  vocab_size=2     )

												return (
												    config,
												    input_ids,
												    attention_mask,
												    encoder_hidden_states,
												    encoder_attention_mask,
												)
					def    _lowerCamelCase (  self:				List[Any]	,  __lowerCamelCase:				Tuple	,  __lowerCamelCase:				str	,  __lowerCamelCase:				Optional[Any]	,  __lowerCamelCase:				List[str]     )    ->				Tuple:
												__UpperCAmelCase						:			Optional[int]         =   20
												__UpperCAmelCase						:			Union[str, Any]         =   model_class_name(__lowerCamelCase     )

												__UpperCAmelCase						:			Optional[Any]         =   model.init_cache(input_ids.shape[0]	,  __lowerCamelCase     )
												__UpperCAmelCase						:			Union[str, Any]         =   jnp.ones((input_ids.shape[0], max_decoder_length)	,  dtype="i4"     )

												__UpperCAmelCase						:			str         =   jnp.broadcast_to(
												    jnp.arange(input_ids.shape[-1] - 1     )[None, :]	,  (input_ids.shape[0], input_ids.shape[-1] - 1)     )
												__UpperCAmelCase						:			Tuple         =   model(
												    input_ids[:, :-1]	,  attention_mask=__lowerCamelCase	,  past_key_values=__lowerCamelCase	,  position_ids=__lowerCamelCase	,  )

												__UpperCAmelCase						:			Dict         =   jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]	,  dtype="i4"     )
												__UpperCAmelCase						:			Tuple         =   model(
												    input_ids[:, -1:]	,  attention_mask=__lowerCamelCase	,  past_key_values=outputs_cache.past_key_values	,  position_ids=__lowerCamelCase	,  )

												__UpperCAmelCase						:			Tuple         =   model(__lowerCamelCase     )

												__UpperCAmelCase						:			Tuple         =   np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])     )     )
												self.parent.assertTrue(diff < 1e-3	,  msg=f'''Max diff is {diff}'''     )





					def    _lowerCamelCase (  self:				Tuple	,  __lowerCamelCase:				Optional[int]	,  __lowerCamelCase:				Any	,  __lowerCamelCase:				List[str]	,  __lowerCamelCase:				str     )    ->				int:
												__UpperCAmelCase						:			str         =   20
												__UpperCAmelCase						:			Tuple         =   model_class_name(__lowerCamelCase     )

												__UpperCAmelCase						:			str         =   jnp.concatenate(
												    [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])     )]	,  axis=-1	,  )

												__UpperCAmelCase						:			List[str]         =   model.init_cache(input_ids.shape[0]	,  __lowerCamelCase     )
												__UpperCAmelCase						:			List[Any]         =   jnp.broadcast_to(
												    jnp.arange(input_ids.shape[-1] - 1     )[None, :]	,  (input_ids.shape[0], input_ids.shape[-1] - 1)     )

												__UpperCAmelCase						:			Tuple         =   model(
												    input_ids[:, :-1]	,  attention_mask=__lowerCamelCase	,  past_key_values=__lowerCamelCase	,  position_ids=__lowerCamelCase	,  )
												__UpperCAmelCase						:			Union[str, Any]         =   jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]	,  dtype="i4"     )
												__UpperCAmelCase						:			Union[str, Any]         =   model(
												    input_ids[:, -1:]	,  past_key_values=outputs_cache.past_key_values	,  attention_mask=__lowerCamelCase	,  position_ids=__lowerCamelCase	,  )

												__UpperCAmelCase						:			List[str]         =   model(__lowerCamelCase	,  attention_mask=__lowerCamelCase     )
												__UpperCAmelCase						:			Optional[Any]         =   np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])     )     )
												self.parent.assertTrue(diff < 1e-3	,  msg=f'''Max diff is {diff}'''     )




@require_sentencepiece
@require_flax
class 					_snake_case						(						_lowercase					,      _lowercase					,      unittest.TestCase				):
					lowerCamelCase__:		List[str]  =     (FlaxXGLMModel, FlaxXGLMForCausalLM) if is_flax_available() else ()
					lowerCamelCase__:		Optional[int]  =     (FlaxXGLMForCausalLM,) if is_flax_available() else ()
					def    _lowerCamelCase (  self:				List[Any]     )    ->				List[str]:
												__UpperCAmelCase						:			List[Any]         =   FlaxXGLMModelTester(self     )
					def    _lowerCamelCase (  self:				Dict     )    ->				Optional[int]:
												for model_class_name in self.all_model_classes:
																			__UpperCAmelCase    ,	__UpperCAmelCase    ,	__UpperCAmelCase						:			int         =   self.model_tester.prepare_config_and_inputs()
																			self.model_tester.check_use_cache_forward(__lowerCamelCase	,  __lowerCamelCase	,  __lowerCamelCase	,  __lowerCamelCase     )
					def    _lowerCamelCase (  self:				List[Any]     )    ->				Tuple:
												for model_class_name in self.all_model_classes:
																			__UpperCAmelCase    ,	__UpperCAmelCase    ,	__UpperCAmelCase						:			str         =   self.model_tester.prepare_config_and_inputs()
																			self.model_tester.check_use_cache_forward_with_attn_mask(
																			    __lowerCamelCase	,  __lowerCamelCase	,  __lowerCamelCase	,  __lowerCamelCase     )
					@slow
					def    _lowerCamelCase (  self:				Dict     )    ->				Any:
												__UpperCAmelCase						:			Optional[int]         =   XGLMTokenizer.from_pretrained("XGLM"	,  padding_side="left"     )
												__UpperCAmelCase						:			str         =   tokenizer(["Hello this is a long string", "Hey"]	,  return_tensors="np"	,  padding=__lowerCamelCase	,  truncation=__lowerCamelCase     )

												__UpperCAmelCase						:			str         =   FlaxXGLMForCausalLM.from_pretrained("facebook/xglm-564M"     )
												__UpperCAmelCase						:			Union[str, Any]         =   1
												__UpperCAmelCase						:			Union[str, Any]         =   False

												__UpperCAmelCase						:			int         =   jax.jit(model.generate     )

												__UpperCAmelCase						:			List[Any]         =   jit_generate(inputs["input_ids"]	,  attention_mask=inputs["attention_mask"]     ).sequences

												__UpperCAmelCase						:			int         =   tokenizer.batch_decode(__lowerCamelCase	,  skip_special_tokens=__lowerCamelCase     )

												__UpperCAmelCase						:			str         =   [
												    "Hello this is a long string of questions, but I'm not sure if I'm",
												    "Hey, I'm a newbie to the forum and I'",
												]

												self.assertListEqual(__lowerCamelCase	,  __lowerCamelCase     )
					@is_pt_flax_cross_test
					def    _lowerCamelCase (  self:				Any     )    ->				Dict:
												__UpperCAmelCase    ,	__UpperCAmelCase						:			Optional[Any]         =   self.model_tester.prepare_config_and_inputs_for_common()

												for model_class in self.all_model_classes:
																			with self.subTest(model_class.__name__     ):
																										# prepare inputs
																										__UpperCAmelCase						:			List[Any]         =   self._prepare_for_class(__lowerCamelCase	,  __lowerCamelCase     )
																										__UpperCAmelCase						:			Union[str, Any]         =   {k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

																										# load corresponding PyTorch class
																										__UpperCAmelCase						:			Union[str, Any]         =   model_class.__name__[4:]  # Skip the "Flax" at the beginning
																										__UpperCAmelCase						:			Union[str, Any]         =   getattr(__lowerCamelCase	,  __lowerCamelCase     )

																										__UpperCAmelCase    ,	__UpperCAmelCase						:			Any         =   pt_inputs["input_ids"].shape
																										__UpperCAmelCase						:			Tuple         =   np.random.randint(0	,  seq_length - 1	,  size=(batch_size,)     )
																										for batch_idx, start_index in enumerate(__lowerCamelCase     ):
																																	__UpperCAmelCase						:			Any         =   0
																																	__UpperCAmelCase						:			List[str]         =   1
																																	__UpperCAmelCase						:			Dict         =   0
																																	__UpperCAmelCase						:			Tuple         =   1
																										__UpperCAmelCase						:			List[str]         =   pt_model_class(__lowerCamelCase     ).eval()
																										# Flax models don't use the `use_cache` option and cache is not returned as a default.
																										# So we disable `use_cache` here for PyTorch model.
																										__UpperCAmelCase						:			Optional[int]         =   False
																										__UpperCAmelCase						:			Optional[int]         =   model_class(__lowerCamelCase	,  dtype=jnp.floataa     )
																										__UpperCAmelCase						:			Union[str, Any]         =   convert_pytorch_state_dict_to_flax(pt_model.state_dict()	,  __lowerCamelCase     )
																										__UpperCAmelCase						:			Dict         =   fx_state

																										with torch.no_grad():
																																	__UpperCAmelCase						:			List[str]         =   pt_model(**__lowerCamelCase     ).to_tuple()

																										__UpperCAmelCase						:			int         =   fx_model(**__lowerCamelCase     ).to_tuple()
																										self.assertEqual(len(__lowerCamelCase     )	,  len(__lowerCamelCase     )	,  "Output lengths differ between Flax and PyTorch"     )
																										for fx_output, pt_output in zip(__lowerCamelCase	,  __lowerCamelCase     ):
																																	self.assert_almost_equals(fx_output[:, -1]	,  pt_output[:, -1].numpy()	,  4e-2     )

																										with tempfile.TemporaryDirectory() as tmpdirname:
																																	pt_model.save_pretrained(__lowerCamelCase     )
																																	__UpperCAmelCase						:			Optional[Any]         =   model_class.from_pretrained(__lowerCamelCase	,  from_pt=__lowerCamelCase     )

																										__UpperCAmelCase						:			Union[str, Any]         =   fx_model_loaded(**__lowerCamelCase     ).to_tuple()
																										self.assertEqual(
																										    len(__lowerCamelCase     )	,  len(__lowerCamelCase     )	,  "Output lengths differ between Flax and PyTorch"     )
																										for fx_output_loaded, pt_output in zip(__lowerCamelCase	,  __lowerCamelCase     ):
																																	self.assert_almost_equals(fx_output_loaded[:, -1]	,  pt_output[:, -1].numpy()	,  4e-2     )
					@is_pt_flax_cross_test
					def    _lowerCamelCase (  self:				Any     )    ->				Tuple:
												__UpperCAmelCase    ,	__UpperCAmelCase						:			str         =   self.model_tester.prepare_config_and_inputs_for_common()
												for model_class in self.all_model_classes:
																			with self.subTest(model_class.__name__     ):
																										# prepare inputs
																										__UpperCAmelCase						:			List[Any]         =   self._prepare_for_class(__lowerCamelCase	,  __lowerCamelCase     )
																										__UpperCAmelCase						:			Tuple         =   {k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

																										# load corresponding PyTorch class
																										__UpperCAmelCase						:			Optional[int]         =   model_class.__name__[4:]  # Skip the "Flax" at the beginning
																										__UpperCAmelCase						:			Dict         =   getattr(__lowerCamelCase	,  __lowerCamelCase     )

																										__UpperCAmelCase						:			int         =   pt_model_class(__lowerCamelCase     ).eval()
																										__UpperCAmelCase						:			Optional[Any]         =   False
																										__UpperCAmelCase						:			List[Any]         =   model_class(__lowerCamelCase	,  dtype=jnp.floataa     )

																										__UpperCAmelCase						:			str         =   load_flax_weights_in_pytorch_model(__lowerCamelCase	,  fx_model.params     )
																										__UpperCAmelCase    ,	__UpperCAmelCase						:			Dict         =   pt_inputs["input_ids"].shape
																										__UpperCAmelCase						:			List[Any]         =   np.random.randint(0	,  seq_length - 1	,  size=(batch_size,)     )
																										for batch_idx, start_index in enumerate(__lowerCamelCase     ):
																																	__UpperCAmelCase						:			List[str]         =   0
																																	__UpperCAmelCase						:			Union[str, Any]         =   1
																																	__UpperCAmelCase						:			Dict         =   0
																																	__UpperCAmelCase						:			List[str]         =   1

																										# make sure weights are tied in PyTorch
																										pt_model.tie_weights()

																										with torch.no_grad():
																																	__UpperCAmelCase						:			Tuple         =   pt_model(**__lowerCamelCase     ).to_tuple()

																										__UpperCAmelCase						:			Tuple         =   fx_model(**__lowerCamelCase     ).to_tuple()
																										self.assertEqual(len(__lowerCamelCase     )	,  len(__lowerCamelCase     )	,  "Output lengths differ between Flax and PyTorch"     )
																										for fx_output, pt_output in zip(__lowerCamelCase	,  __lowerCamelCase     ):
																																	self.assert_almost_equals(fx_output[:, -1]	,  pt_output[:, -1].numpy()	,  4e-2     )

																										with tempfile.TemporaryDirectory() as tmpdirname:
																																	fx_model.save_pretrained(__lowerCamelCase     )
																																	__UpperCAmelCase						:			Union[str, Any]         =   pt_model_class.from_pretrained(__lowerCamelCase	,  from_flax=__lowerCamelCase     )

																										with torch.no_grad():
																																	__UpperCAmelCase						:			Union[str, Any]         =   pt_model_loaded(**__lowerCamelCase     ).to_tuple()

																										self.assertEqual(
																										    len(__lowerCamelCase     )	,  len(__lowerCamelCase     )	,  "Output lengths differ between Flax and PyTorch"     )
																										for fx_output, pt_output in zip(__lowerCamelCase	,  __lowerCamelCase     ):
																																	self.assert_almost_equals(fx_output[:, -1]	,  pt_output[:, -1].numpy()	,  4e-2     )





					@slow
					def    _lowerCamelCase (  self:				Optional[Any]     )    ->				Union[str, Any]:
												for model_class_name in self.all_model_classes:
																			__UpperCAmelCase						:			int         =   model_class_name.from_pretrained("facebook/xglm-564M"     )
																			__UpperCAmelCase						:			Union[str, Any]         =   model(np.ones((1, 1)     )     )
																			self.assertIsNotNone(__lowerCamelCase     )





import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput




@dataclass
class 					_snake_case						(						_lowercase				):
					lowerCamelCase__:		float
					lowerCamelCase__:		Optional[float]  =     None
					lowerCamelCase__:		Optional[float]  =     None




class 					_snake_case						(						unittest.TestCase				):
					def    _lowerCamelCase (  self:				Union[str, Any]     )    ->				List[Any]:
												__UpperCAmelCase						:			str         =   ModelOutputTest(a=30     )
												self.assertEqual(x.a	,  30     )
												self.assertIsNone(x.b     )
												self.assertIsNone(x.c     )
												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			List[Any]         =   x.d
					def    _lowerCamelCase (  self:				Optional[int]     )    ->				str:
												__UpperCAmelCase						:			Union[str, Any]         =   ModelOutputTest(a=30	,  b=10     )
												self.assertEqual(x[0]	,  30     )
												self.assertEqual(x[1]	,  10     )
												self.assertEqual(x[:2]	,  (30, 10)     )
												self.assertEqual(x[:]	,  (30, 10)     )

												__UpperCAmelCase						:			Optional[Any]         =   ModelOutputTest(a=30	,  c=10     )
												self.assertEqual(x[0]	,  30     )
												self.assertEqual(x[1]	,  10     )
												self.assertEqual(x[:2]	,  (30, 10)     )
												self.assertEqual(x[:]	,  (30, 10)     )
					def    _lowerCamelCase (  self:				Tuple     )    ->				List[str]:
												__UpperCAmelCase						:			str         =   ModelOutputTest(a=30	,  b=10     )
												self.assertEqual(x["a"]	,  30     )
												self.assertEqual(x["b"]	,  10     )
												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			Dict         =   x["c"]

												__UpperCAmelCase						:			Tuple         =   ModelOutputTest(a=30	,  c=10     )
												self.assertEqual(x["a"]	,  30     )
												self.assertEqual(x["c"]	,  10     )
												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			Optional[Any]         =   x["b"]
					def    _lowerCamelCase (  self:				str     )    ->				Any:
												__UpperCAmelCase						:			Union[str, Any]         =   ModelOutputTest(a=30     )
												self.assertEqual(list(x.keys()     )	,  ["a"]     )
												self.assertEqual(list(x.values()     )	,  [30]     )
												self.assertEqual(list(x.items()     )	,  [("a", 30)]     )
												self.assertEqual(list(__lowerCamelCase     )	,  ["a"]     )

												__UpperCAmelCase						:			str         =   ModelOutputTest(a=30	,  b=10     )
												self.assertEqual(list(x.keys()     )	,  ["a", "b"]     )
												self.assertEqual(list(x.values()     )	,  [30, 10]     )
												self.assertEqual(list(x.items()     )	,  [("a", 30), ("b", 10)]     )
												self.assertEqual(list(__lowerCamelCase     )	,  ["a", "b"]     )

												__UpperCAmelCase						:			Any         =   ModelOutputTest(a=30	,  c=10     )
												self.assertEqual(list(x.keys()     )	,  ["a", "c"]     )
												self.assertEqual(list(x.values()     )	,  [30, 10]     )
												self.assertEqual(list(x.items()     )	,  [("a", 30), ("c", 10)]     )
												self.assertEqual(list(__lowerCamelCase     )	,  ["a", "c"]     )

												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			Dict         =   x.update({"d": 20}     )
												with self.assertRaises(__lowerCamelCase     ):
																			del x["a"]
												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			List[Any]         =   x.pop("a"     )
												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			str         =   x.setdefault("d"	,  32     )
					def    _lowerCamelCase (  self:				List[str]     )    ->				str:
												__UpperCAmelCase						:			Optional[Any]         =   ModelOutputTest(a=30     )
												__UpperCAmelCase						:			Tuple         =   10
												self.assertEqual(x.a	,  10     )
												self.assertEqual(x["a"]	,  10     )
					def    _lowerCamelCase (  self:				Optional[int]     )    ->				Dict:
												__UpperCAmelCase						:			str         =   ModelOutputTest(a=30     )
												__UpperCAmelCase						:			Optional[int]         =   10
												self.assertEqual(x.a	,  10     )
												self.assertEqual(x["a"]	,  10     )
					def    _lowerCamelCase (  self:				List[Any]     )    ->				Optional[int]:
												__UpperCAmelCase						:			Tuple         =   ModelOutputTest({"a": 30, "b": 10}     )
												self.assertEqual(list(x.keys()     )	,  ["a", "b"]     )
												self.assertEqual(x.a	,  30     )
												self.assertEqual(x.b	,  10     )





					def    _lowerCamelCase (  self:				Optional[int]     )    ->				Union[str, Any]:
												__UpperCAmelCase						:			Dict         =   ModelOutputTest([("a", 30), ("b", 10)]     )
												self.assertEqual(list(x.keys()     )	,  ["a", "b"]     )
												self.assertEqual(x.a	,  30     )
												self.assertEqual(x.b	,  10     )

												with self.assertRaises(__lowerCamelCase     ):
																			__UpperCAmelCase						:			Any         =   ModelOutputTest([("a", 30), (10, 10)]     )

												__UpperCAmelCase						:			Dict         =   ModelOutputTest(a=(30, 30)     )
												self.assertEqual(list(x.keys()     )	,  ["a"]     )
												self.assertEqual(x.a	,  (30, 30)     )




