
"""simple docstring"""




import unittest

from transformers import AlbertConfig, is_torch_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, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers import (
						    MODEL_FOR_PRETRAINING_MAPPING,
						    AlbertForMaskedLM,
						    AlbertForMultipleChoice,
						    AlbertForPreTraining,
						    AlbertForQuestionAnswering,
						    AlbertForSequenceClassification,
						    AlbertForTokenClassification,
						    AlbertModel,
						)
						from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST





class  snake_case     :

							def __init__(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_=13       ,       SCREAMING_SNAKE_CASE_=7       ,       SCREAMING_SNAKE_CASE_=True       ,       SCREAMING_SNAKE_CASE_=True       ,       SCREAMING_SNAKE_CASE_=True       ,       SCREAMING_SNAKE_CASE_=True       ,       SCREAMING_SNAKE_CASE_=99       ,       SCREAMING_SNAKE_CASE_=16       ,       SCREAMING_SNAKE_CASE_=36       ,       SCREAMING_SNAKE_CASE_=6       ,       SCREAMING_SNAKE_CASE_=6       ,       SCREAMING_SNAKE_CASE_=6       ,       SCREAMING_SNAKE_CASE_=37       ,       SCREAMING_SNAKE_CASE_="gelu"       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=0.1       ,       SCREAMING_SNAKE_CASE_=5_12       ,       SCREAMING_SNAKE_CASE_=16       ,       SCREAMING_SNAKE_CASE_=2       ,       SCREAMING_SNAKE_CASE_=0.02       ,       SCREAMING_SNAKE_CASE_=3       ,       SCREAMING_SNAKE_CASE_=4       ,       SCREAMING_SNAKE_CASE_=None       ,       ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = parent
									SCREAMING_SNAKE_CASE_						 = batch_size
									SCREAMING_SNAKE_CASE_						 = seq_length
									SCREAMING_SNAKE_CASE_						 = is_training
									SCREAMING_SNAKE_CASE_						 = use_input_mask
									SCREAMING_SNAKE_CASE_						 = use_token_type_ids
									SCREAMING_SNAKE_CASE_						 = use_labels
									SCREAMING_SNAKE_CASE_						 = vocab_size
									SCREAMING_SNAKE_CASE_						 = embedding_size
									SCREAMING_SNAKE_CASE_						 = hidden_size
									SCREAMING_SNAKE_CASE_						 = num_hidden_layers
									SCREAMING_SNAKE_CASE_						 = num_hidden_groups
									SCREAMING_SNAKE_CASE_						 = num_attention_heads
									SCREAMING_SNAKE_CASE_						 = intermediate_size
									SCREAMING_SNAKE_CASE_						 = hidden_act
									SCREAMING_SNAKE_CASE_						 = hidden_dropout_prob
									SCREAMING_SNAKE_CASE_						 = attention_probs_dropout_prob
									SCREAMING_SNAKE_CASE_						 = max_position_embeddings
									SCREAMING_SNAKE_CASE_						 = type_vocab_size
									SCREAMING_SNAKE_CASE_						 = type_sequence_label_size
									SCREAMING_SNAKE_CASE_						 = initializer_range
									SCREAMING_SNAKE_CASE_						 = num_labels
									SCREAMING_SNAKE_CASE_						 = num_choices
									SCREAMING_SNAKE_CASE_						 = scope

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size, self.seq_length]       ,       self.vocab_size    )

									SCREAMING_SNAKE_CASE_						 = None
									if self.use_input_mask:
											SCREAMING_SNAKE_CASE_						 = random_attention_mask([self.batch_size, self.seq_length]    )

									SCREAMING_SNAKE_CASE_						 = None
									if self.use_token_type_ids:
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size, self.seq_length]       ,       self.type_vocab_size    )

									SCREAMING_SNAKE_CASE_						 = None
									SCREAMING_SNAKE_CASE_						 = None
									SCREAMING_SNAKE_CASE_						 = None
									if self.use_labels:
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size]       ,       self.type_sequence_label_size    )
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size, self.seq_length]       ,       self.num_labels    )
											SCREAMING_SNAKE_CASE_						 = ids_tensor([self.batch_size]       ,       self.num_choices    )

									SCREAMING_SNAKE_CASE_						 = self.get_config()

									return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels

							def _lowercase					(self    ):

									"""simple docstring"""







									return AlbertConfig(
									    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       ,       num_hidden_groups=self.num_hidden_groups       ,       )

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = AlbertModel(config=SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_    )
									self.parent.assertEqual(result.last_hidden_state.shape       ,       (self.batch_size, self.seq_length, self.hidden_size)    )
									self.parent.assertEqual(result.pooler_output.shape       ,       (self.batch_size, self.hidden_size)    )

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = AlbertForPreTraining(config=SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(
									    SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_       ,       labels=SCREAMING_SNAKE_CASE_       ,       sentence_order_label=SCREAMING_SNAKE_CASE_       ,       )
									self.parent.assertEqual(result.prediction_logits.shape       ,       (self.batch_size, self.seq_length, self.vocab_size)    )
									self.parent.assertEqual(result.sop_logits.shape       ,       (self.batch_size, config.num_labels)    )

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = AlbertForMaskedLM(config=SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_       ,       labels=SCREAMING_SNAKE_CASE_    )
									self.parent.assertEqual(result.logits.shape       ,       (self.batch_size, self.seq_length, self.vocab_size)    )

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = AlbertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(
									    SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_       ,       start_positions=SCREAMING_SNAKE_CASE_       ,       end_positions=SCREAMING_SNAKE_CASE_       ,       )
									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 _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.num_labels
									SCREAMING_SNAKE_CASE_						 = AlbertForSequenceClassification(SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_       ,       labels=SCREAMING_SNAKE_CASE_    )
									self.parent.assertEqual(result.logits.shape       ,       (self.batch_size, self.num_labels)    )

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.num_labels
									SCREAMING_SNAKE_CASE_						 = AlbertForTokenClassification(config=SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_       ,       labels=SCREAMING_SNAKE_CASE_    )
									self.parent.assertEqual(result.logits.shape       ,       (self.batch_size, self.seq_length, self.num_labels)    )

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.num_choices
									SCREAMING_SNAKE_CASE_						 = AlbertForMultipleChoice(config=SCREAMING_SNAKE_CASE_    )
									model.to(SCREAMING_SNAKE_CASE_    )
									model.eval()
									SCREAMING_SNAKE_CASE_						 = input_ids.unsqueeze(1    ).expand(-1       ,       self.num_choices       ,       -1    ).contiguous()
									SCREAMING_SNAKE_CASE_						 = token_type_ids.unsqueeze(1    ).expand(-1       ,       self.num_choices       ,       -1    ).contiguous()
									SCREAMING_SNAKE_CASE_						 = input_mask.unsqueeze(1    ).expand(-1       ,       self.num_choices       ,       -1    ).contiguous()
									SCREAMING_SNAKE_CASE_						 = model(
									    SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_       ,       token_type_ids=SCREAMING_SNAKE_CASE_       ,       labels=SCREAMING_SNAKE_CASE_       ,       )
									self.parent.assertEqual(result.logits.shape       ,       (self.batch_size, self.num_choices)    )







							def _lowercase					(self    ):

									"""simple docstring"""







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







@require_torch
class  snake_case     (							__lowercase       ,			__lowercase       ,			unittest.TestCase   ):
							UpperCAmelCase__						     =      (
							    (
							        AlbertModel,
							        AlbertForPreTraining,
							        AlbertForMaskedLM,
							        AlbertForMultipleChoice,
							        AlbertForSequenceClassification,
							        AlbertForTokenClassification,
							        AlbertForQuestionAnswering,
							    )
							    if is_torch_available()
							    else ()
							)
							UpperCAmelCase__						     =      (
							    {
							        '''feature-extraction''': AlbertModel,
							        '''fill-mask''': AlbertForMaskedLM,
							        '''question-answering''': AlbertForQuestionAnswering,
							        '''text-classification''': AlbertForSequenceClassification,
							        '''token-classification''': AlbertForTokenClassification,
							        '''zero-shot''': AlbertForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							UpperCAmelCase__						     =      True

							def _lowercase					(self       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_=False    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = super()._prepare_for_class(SCREAMING_SNAKE_CASE_       ,       SCREAMING_SNAKE_CASE_       ,       return_labels=SCREAMING_SNAKE_CASE_    )

									if return_labels:
											if model_class in get_values(SCREAMING_SNAKE_CASE_    ):
													SCREAMING_SNAKE_CASE_						 = torch.zeros(
													    (self.model_tester.batch_size, self.model_tester.seq_length)       ,       dtype=torch.long       ,       device=SCREAMING_SNAKE_CASE_    )
													SCREAMING_SNAKE_CASE_						 = torch.zeros(
													    self.model_tester.batch_size       ,       dtype=torch.long       ,       device=SCREAMING_SNAKE_CASE_    )
									return inputs_dict

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = AlbertModelTester(self    )
									SCREAMING_SNAKE_CASE_						 = ConfigTester(self       ,       config_class=SCREAMING_SNAKE_CASE_       ,       hidden_size=37    )

							def _lowercase					(self    ):

									"""simple docstring"""







									self.config_tester.run_common_tests()

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_    )

							def _lowercase					(self    ):

									"""simple docstring"""







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







							@slow
							def _lowercase					(self    ):

									"""simple docstring"""







									for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											SCREAMING_SNAKE_CASE_						 = AlbertModel.from_pretrained(SCREAMING_SNAKE_CASE_    )
											self.assertIsNotNone(SCREAMING_SNAKE_CASE_    )







@require_torch
class  snake_case     (							unittest.TestCase   ):

							@slow
							def _lowercase					(self    ):

									"""simple docstring"""







									SCREAMING_SNAKE_CASE_						 = AlbertModel.from_pretrained('''albert-base-v2'''    )
									SCREAMING_SNAKE_CASE_						 = torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]    )
									SCREAMING_SNAKE_CASE_						 = torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]    )
									with torch.no_grad():
											SCREAMING_SNAKE_CASE_						 = model(SCREAMING_SNAKE_CASE_       ,       attention_mask=SCREAMING_SNAKE_CASE_    )[0]
									SCREAMING_SNAKE_CASE_						 = torch.Size((1, 11, 7_68)    )
									self.assertEqual(output.shape       ,       SCREAMING_SNAKE_CASE_    )
									SCREAMING_SNAKE_CASE_						 = torch.tensor(
									    [[[-0.65_13, 1.50_35, -0.27_66], [-0.65_15, 1.50_46, -0.27_80], [-0.65_12, 1.50_49, -0.27_84]]]    )

									self.assertTrue(torch.allclose(output[:, 1:4, 1:4]       ,       SCREAMING_SNAKE_CASE_       ,       atol=1e-4    )    )

"""simple docstring"""




import os
import socket
from contextlib import contextmanager

import torch

from ..commands.config.default import write_basic_config  # noqa: F401
from ..state import PartialState
from .dataclasses import DistributedType
from .imports import is_deepspeed_available, is_tpu_available
from .transformer_engine import convert_model
from .versions import is_torch_version


if is_deepspeed_available():
						from deepspeed import DeepSpeedEngine

if is_tpu_available(check_device=False):
						import torch_xla.core.xla_model as xm



def        _lowerCamelCase ( __a    ):
		if is_torch_version('''<''',							'''2.0.0'''    ) or not hasattr(__a,							'''_dynamo'''    ):
				return False
		return isinstance(__a,							torch._dynamo.eval_frame.OptimizedModule    )



def        _lowerCamelCase ( __a,							__a = True    ):
		SCREAMING_SNAKE_CASE_						 = (torch.nn.parallel.DistributedDataParallel, torch.nn.DataParallel)

		SCREAMING_SNAKE_CASE_						 = is_compiled_module(__a    )
		if is_compiled:
				SCREAMING_SNAKE_CASE_						 = model
				SCREAMING_SNAKE_CASE_						 = model._orig_mod

		if is_deepspeed_available():
				options += (DeepSpeedEngine,)

		while isinstance(__a,							__a    ):
				SCREAMING_SNAKE_CASE_						 = model.module

		if not keep_fpaa_wrapper:
				SCREAMING_SNAKE_CASE_						 = getattr(__a,							'''forward'''    )
				SCREAMING_SNAKE_CASE_						 = model.__dict__.pop('''_original_forward''',							__a    )
				if original_forward is not None:
						while hasattr(__a,							'''__wrapped__'''    ):
								SCREAMING_SNAKE_CASE_						 = forward.__wrapped__
								if forward == original_forward:
										break
						SCREAMING_SNAKE_CASE_						 = forward
				if getattr(__a,							'''_converted_to_transformer_engine''',							__a    ):
						convert_model(__a,							to_transformer_engine=__a    )

		if is_compiled:
				SCREAMING_SNAKE_CASE_						 = model
				SCREAMING_SNAKE_CASE_						 = compiled_model

		return model



def        _lowerCamelCase ( ):
		PartialState().wait_for_everyone()



def        _lowerCamelCase ( __a,							__a    ):
		if PartialState().distributed_type == DistributedType.TPU:
				xm.save(__a,							__a    )
		elif PartialState().local_process_index == 0:
				torch.save(__a,							__a    )



@contextmanager
def        _lowerCamelCase ( **__a    ):
		for key, value in kwargs.items():
				SCREAMING_SNAKE_CASE_						 = str(__a    )

		yield

		for key in kwargs:
				if key.upper() in os.environ:
						del os.environ[key.upper()]



def        _lowerCamelCase ( __a    ):
		if not hasattr(__a,							'''__qualname__'''    ) and not hasattr(__a,							'''__name__'''    ):
				SCREAMING_SNAKE_CASE_						 = getattr(__a,							'''__class__''',							__a    )
		if hasattr(__a,							'''__qualname__'''    ):
				return obj.__qualname__
		if hasattr(__a,							'''__name__'''    ):
				return obj.__name__
		return str(__a    )



def        _lowerCamelCase ( __a,							__a    ):
		for key, value in source.items():
				if isinstance(__a,							__a    ):
						SCREAMING_SNAKE_CASE_						 = destination.setdefault(__a,							{}    )
						merge_dicts(__a,							__a    )
				else:
						SCREAMING_SNAKE_CASE_						 = value

		return destination



def        _lowerCamelCase ( __a = None    ):
		if port is None:
				SCREAMING_SNAKE_CASE_						 = 29_500
		with socket.socket(socket.AF_INET,							socket.SOCK_STREAM    ) as s:
				return s.connect_ex(('''localhost''', port)    ) == 0