





import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, 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

				from transformers.modeling_flax_pytorch_utils import (
				    convert_pytorch_state_dict_to_flax,
				    load_flax_weights_in_pytorch_model,
				)
				from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
				import torch



class  _a  :






							"""simple docstring"""

							def __init__(   self					:  Union[str, Any]				,						a					:  Any				,						a					:  str=14				,						a					:  List[str]=7				,						a					:  List[str]=True				,						a					:  Optional[int]=True				,						a					:  List[Any]=False				,						a					:  Any=True				,						a					:  Any=99				,						a					:  str=32				,						a					:  List[str]=5				,						a					:  List[str]=4				,						a					:  List[Any]=37				,						a					:  int="gelu"				,						a					:  Any=0.1				,						a					:  Dict=0.1				,						a					:  Dict=5_12				,						a					:  Tuple=0.02				,						)						->int:
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       parent
													SCREAMING_SNAKE_CASE__  :					Dict =       batch_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       seq_length
													SCREAMING_SNAKE_CASE__  :					int =       is_training
													SCREAMING_SNAKE_CASE__  :					Tuple =       use_input_mask
													SCREAMING_SNAKE_CASE__  :					List[Any] =       use_token_type_ids
													SCREAMING_SNAKE_CASE__  :					Any =       use_labels
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       vocab_size
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       num_hidden_layers
													SCREAMING_SNAKE_CASE__  :					List[Any] =       num_attention_heads
													SCREAMING_SNAKE_CASE__  :					List[str] =       intermediate_size
													SCREAMING_SNAKE_CASE__  :					str =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Any =       hidden_dropout_prob
													SCREAMING_SNAKE_CASE__  :					int =       attention_probs_dropout_prob
													SCREAMING_SNAKE_CASE__  :					str =       max_position_embeddings
													SCREAMING_SNAKE_CASE__  :					Tuple =       initializer_range
													SCREAMING_SNAKE_CASE__  :					int =       None
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       vocab_size - 1
													SCREAMING_SNAKE_CASE__  :					List[Any] =       vocab_size - 1
													SCREAMING_SNAKE_CASE__  :					str =       vocab_size - 1

							def   A_	(   self					:  Dict     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					Dict =       ids_tensor([self.batch_size, self.seq_length]				,						self.vocab_size     )

													SCREAMING_SNAKE_CASE__  :					Optional[int] =       None
													if self.use_input_mask:
																			SCREAMING_SNAKE_CASE__  :					Optional[Any] =       random_attention_mask([self.batch_size, self.seq_length]     )

													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       GPTaConfig(
													    vocab_size=self.vocab_size				,						n_embd=self.hidden_size				,						n_layer=self.num_hidden_layers				,						n_head=self.num_attention_heads				,						n_positions=self.max_position_embeddings				,						use_cache=a				,						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   A_	(   self					:  Union[str, Any]     )						->Any:
													SCREAMING_SNAKE_CASE__  :					Tuple =       self.prepare_config_and_inputs()
													SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					Tuple =       config_and_inputs
													SCREAMING_SNAKE_CASE__  :					str =       {"input_ids": input_ids, "attention_mask": attention_mask}
													return config, inputs_dict

							def   A_	(   self					:  Tuple     )						->int:
													SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					str =       self.prepare_config_and_inputs()

													SCREAMING_SNAKE_CASE__  :					Dict =       floats_tensor([self.batch_size, self.seq_length, self.hidden_size]     )
													SCREAMING_SNAKE_CASE__  :					Union[str, 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   A_	(   self					:  Optional[Any]				,						a					:  Tuple				,						a					:  Dict				,						a					:  int				,						a					:  int     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					int =       20
													SCREAMING_SNAKE_CASE__  :					List[Any] =       model_class_name(a     )

													SCREAMING_SNAKE_CASE__  :					List[str] =       model.init_cache(input_ids.shape[0]				,						a     )
													SCREAMING_SNAKE_CASE__  :					int =       jnp.ones((input_ids.shape[0], max_decoder_length)				,						dtype="i4"     )

													SCREAMING_SNAKE_CASE__  :					int =       jnp.broadcast_to(
													    jnp.arange(input_ids.shape[-1] - 1     )[None, :]				,						(input_ids.shape[0], input_ids.shape[-1] - 1)     )
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       model(
													    input_ids[:, :-1]				,						attention_mask=a				,						past_key_values=a				,						position_ids=a				,						)

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

													SCREAMING_SNAKE_CASE__  :					List[Any] =       model(a     )

													SCREAMING_SNAKE_CASE__  :					str =       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   A_	(   self					:  Optional[Any]				,						a					:  Any				,						a					:  List[Any]				,						a					:  Any				,						a					:  List[Any]     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       20
													SCREAMING_SNAKE_CASE__  :					Any =       model_class_name(a     )

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

													SCREAMING_SNAKE_CASE__  :					Tuple =       model.init_cache(input_ids.shape[0]				,						a     )
													SCREAMING_SNAKE_CASE__  :					Tuple =       jnp.broadcast_to(
													    jnp.arange(input_ids.shape[-1] - 1     )[None, :]				,						(input_ids.shape[0], input_ids.shape[-1] - 1)     )

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

													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       model(a				,						attention_mask=a     )

													SCREAMING_SNAKE_CASE__  :					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_flax
class  _a  (					lowercase__       ,				lowercase__       ,				unittest.TestCase				):






							"""simple docstring"""

							snake_case_							=    (FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
							snake_case_							=    (FlaxGPTaLMHeadModel,) if is_flax_available() else ()

							def   A_	(   self					:  Dict     )						->List[str]:
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       FlaxGPTaModelTester(self     )

							def   A_	(   self					:  Union[str, Any]     )						->Optional[Any]:
													for model_class_name in self.all_model_classes:
																			SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					str =       self.model_tester.prepare_config_and_inputs()
																			self.model_tester.check_use_cache_forward(a				,						a				,						a				,						a     )

							def   A_	(   self					:  str     )						->List[str]:
													for model_class_name in self.all_model_classes:
																			SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.model_tester.prepare_config_and_inputs()
																			self.model_tester.check_use_cache_forward_with_attn_mask(
																			    a				,						a				,						a				,						a     )

							@slow
							def   A_	(   self					:  Optional[int]     )						->int:
													SCREAMING_SNAKE_CASE__  :					List[str] =       GPTaTokenizer.from_pretrained("gpt2"				,						pad_token="</s>"				,						padding_side="left"     )
													SCREAMING_SNAKE_CASE__  :					Any =       tokenizer(["Hello this is a long string", "Hey"]				,						return_tensors="np"				,						padding=a				,						truncation=a     )

													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       FlaxGPTaLMHeadModel.from_pretrained("gpt2"     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       False
													SCREAMING_SNAKE_CASE__  :					List[str] =       model.config.eos_token_id

													SCREAMING_SNAKE_CASE__  :					List[str] =       jax.jit(model.generate     )

													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       jit_generate(inputs["input_ids"]				,						attention_mask=inputs["attention_mask"]     ).sequences

													SCREAMING_SNAKE_CASE__  :					Dict =       tokenizer.batch_decode(a				,						skip_special_tokens=a     )

													SCREAMING_SNAKE_CASE__  :					str =       [
													    "Hello this is a long string of words. I'm going to start with the first one.\n",
													    "Hey, I'm not sure if I'm going to be able to do",
													]

													self.assertListEqual(a				,						a     )

							@is_pt_flax_cross_test
							def   A_	(   self					:  Tuple     )						->List[Any]:
													SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					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
																									SCREAMING_SNAKE_CASE__  :					Tuple =       self._prepare_for_class(a				,						a     )
																									SCREAMING_SNAKE_CASE__  :					Any =       {k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

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

																									SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					List[Any] =       pt_inputs["input_ids"].shape
																									SCREAMING_SNAKE_CASE__  :					Optional[int] =       np.random.randint(0				,						seq_length - 1				,						size=(batch_size,)     )
																									for batch_idx, start_index in enumerate(a     ):
																															SCREAMING_SNAKE_CASE__  :					List[Any] =       0
																															SCREAMING_SNAKE_CASE__  :					Tuple =       1
																															SCREAMING_SNAKE_CASE__  :					str =       0
																															SCREAMING_SNAKE_CASE__  :					Optional[int] =       1
																									SCREAMING_SNAKE_CASE__  :					int =       pt_model_class(a     ).eval()
																									SCREAMING_SNAKE_CASE__  :					Any =       model_class(a				,						dtype=jnp.floataa     )

																									SCREAMING_SNAKE_CASE__  :					Any =       convert_pytorch_state_dict_to_flax(pt_model.state_dict()				,						a     )
																									SCREAMING_SNAKE_CASE__  :					int =       fx_state

																									with torch.no_grad():
																															SCREAMING_SNAKE_CASE__  :					Tuple =       pt_model(**a     ).to_tuple()

																									SCREAMING_SNAKE_CASE__  :					List[Any] =       fx_model(**a     ).to_tuple()
																									self.assertEqual(len(a     )				,						len(a     )				,						"Output lengths differ between Flax and PyTorch"     )
																									for fx_output, pt_output in zip(a				,						a     ):
																															self.assert_almost_equals(fx_output[:, -1]				,						pt_output[:, -1].numpy()				,						4E-2     )

																									with tempfile.TemporaryDirectory() as tmpdirname:
																															pt_model.save_pretrained(a     )
																															SCREAMING_SNAKE_CASE__  :					str =       model_class.from_pretrained(a				,						from_pt=a     )

																									SCREAMING_SNAKE_CASE__  :					Dict =       fx_model_loaded(**a     ).to_tuple()
																									self.assertEqual(
																									    len(a     )				,						len(a     )				,						"Output lengths differ between Flax and PyTorch"     )
																									for fx_output_loaded, pt_output in zip(a				,						a     ):
																															self.assert_almost_equals(fx_output_loaded[:, -1]				,						pt_output[:, -1].numpy()				,						4E-2     )

							@is_pt_flax_cross_test
							def   A_	(   self					:  Dict     )						->Dict:
													SCREAMING_SNAKE_CASE__,				SCREAMING_SNAKE_CASE__  :					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
																									SCREAMING_SNAKE_CASE__  :					List[Any] =       self._prepare_for_class(a				,						a     )
																									SCREAMING_SNAKE_CASE__  :					int =       {k: torch.tensor(v.tolist()     ) for k, v in prepared_inputs_dict.items()}

																									# load corresponding PyTorch class
																									SCREAMING_SNAKE_CASE__  :					Optional[Any] =       model_class.__name__[4:]  # Skip the "Flax" at the beginning
																									SCREAMING_SNAKE_CASE__  :					Any =       getattr(a				,						a     )

																									SCREAMING_SNAKE_CASE__  :					Optional[Any] =       pt_model_class(a     ).eval()
																									SCREAMING_SNAKE_CASE__  :					List[str] =       model_class(a				,						dtype=jnp.floataa     )

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

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

																									with torch.no_grad():
																															SCREAMING_SNAKE_CASE__  :					List[str] =       pt_model(**a     ).to_tuple()

																									SCREAMING_SNAKE_CASE__  :					Optional[Any] =       fx_model(**a     ).to_tuple()
																									self.assertEqual(len(a     )				,						len(a     )				,						"Output lengths differ between Flax and PyTorch"     )
																									for fx_output, pt_output in zip(a				,						a     ):
																															self.assert_almost_equals(fx_output[:, -1]				,						pt_output[:, -1].numpy()				,						4E-2     )

																									with tempfile.TemporaryDirectory() as tmpdirname:
																															fx_model.save_pretrained(a     )
																															SCREAMING_SNAKE_CASE__  :					Optional[int] =       pt_model_class.from_pretrained(a				,						from_flax=a     )

																									with torch.no_grad():
																															SCREAMING_SNAKE_CASE__  :					List[str] =       pt_model_loaded(**a     ).to_tuple()

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






							@slow
							def   A_	(   self					:  Optional[int]     )						->Tuple:
													for model_class_name in self.all_model_classes:
																			SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       model_class_name.from_pretrained("gpt2"				,						from_pt=a     )
																			SCREAMING_SNAKE_CASE__  :					Tuple =       model(np.ones((1, 1)     )     )
																			self.assertIsNotNone(a     )






import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowercase							:List[Any]							=	logging.get_logger(__name__)

__lowercase							:Optional[Any]							=	{
    "facebook/sam-vit-huge": "https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json",
    "facebook/sam-vit-large": "https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json",
    "facebook/sam-vit-base": "https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json",
}



class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  List[Any]				,						a					:  int=2_56				,						a					:  Tuple=10_24				,						a					:  Optional[Any]=16				,						a					:  Dict=16				,						a					:  str=4				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[Any]=1E-6				,						**a					:  Dict				,						)						->Union[str, Any]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Any =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       image_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       patch_size
													SCREAMING_SNAKE_CASE__  :					str =       image_size // patch_size
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       mask_input_channels
													SCREAMING_SNAKE_CASE__  :					Any =       num_point_embeddings
													SCREAMING_SNAKE_CASE__  :					str =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Union[str, Any]				,						a					:  Optional[int]=2_56				,						a					:  Dict="relu"				,						a					:  Dict=20_48				,						a					:  Union[str, Any]=2				,						a					:  str=8				,						a					:  str=2				,						a					:  List[Any]=3				,						a					:  str=3				,						a					:  List[str]=2_56				,						a					:  str=1E-6				,						**a					:  Optional[int]				,						)						->Dict:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Dict =       mlp_dim
													SCREAMING_SNAKE_CASE__  :					List[Any] =       num_hidden_layers
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       num_attention_heads
													SCREAMING_SNAKE_CASE__  :					List[Any] =       attention_downsample_rate
													SCREAMING_SNAKE_CASE__  :					List[str] =       num_multimask_outputs
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       iou_head_depth
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       iou_head_hidden_dim
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Tuple				,						a					:  str=7_68				,						a					:  Tuple=2_56				,						a					:  Tuple=12				,						a					:  List[str]=12				,						a					:  Optional[Any]=3				,						a					:  str=10_24				,						a					:  str=16				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[int]=1E-06				,						a					:  Optional[Any]=0.0				,						a					:  str=1E-10				,						a					:  Optional[int]=True				,						a					:  Dict=4.0				,						a					:  Optional[Any]=True				,						a					:  List[str]=True				,						a					:  str=14				,						a					:  List[str]=[2, 5, 8, 11]				,						a					:  int=1_28				,						a					:  int=None				,						**a					:  List[str]				,						)						->Union[str, Any]:
													super().__init__(**a     )

													SCREAMING_SNAKE_CASE__  :					Tuple =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       output_channels
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       num_hidden_layers
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       num_attention_heads
													SCREAMING_SNAKE_CASE__  :					List[str] =       num_channels
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       image_size
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       patch_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       hidden_act
													SCREAMING_SNAKE_CASE__  :					str =       layer_norm_eps
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       attention_dropout
													SCREAMING_SNAKE_CASE__  :					List[Any] =       initializer_range
													SCREAMING_SNAKE_CASE__  :					Tuple =       qkv_bias
													SCREAMING_SNAKE_CASE__  :					Tuple =       mlp_ratio
													SCREAMING_SNAKE_CASE__  :					Tuple =       use_abs_pos
													SCREAMING_SNAKE_CASE__  :					Dict =       use_rel_pos
													SCREAMING_SNAKE_CASE__  :					Tuple =       window_size
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       global_attn_indexes
													SCREAMING_SNAKE_CASE__  :					Any =       num_pos_feats
													SCREAMING_SNAKE_CASE__  :					int =       int(hidden_size * mlp_ratio     ) if mlp_dim is None else mlp_dim







class  _a  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    "sam"
							snake_case_							=    True

							def __init__(   self					:  str				,						a					:  Optional[int]=None				,						a					:  Any=None				,						a					:  Any=None				,						a					:  str=0.02				,						**a					:  int				,						)						->Optional[int]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Dict =       vision_config if vision_config is not None else {}
													SCREAMING_SNAKE_CASE__  :					str =       prompt_encoder_config if prompt_encoder_config is not None else {}
													SCREAMING_SNAKE_CASE__  :					Tuple =       mask_decoder_config if mask_decoder_config is not None else {}

													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Tuple =       vision_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Dict =       prompt_encoder_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       mask_decoder_config.to_dict()

													SCREAMING_SNAKE_CASE__  :					str =       SamVisionConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					str =       SamPromptEncoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					int =       SamMaskDecoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					List[str] =       initializer_range






							def   A_	(   self					:  str     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					int =       copy.deepcopy(self.__dict__     )
													SCREAMING_SNAKE_CASE__  :					str =       self.vision_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       self.prompt_encoder_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.mask_decoder_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Tuple =       self.__class__.model_type
													return output