






"""simple docstring"""
from typing import Optional, Union

import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_mobilenet_va import MobileNetVaConfig


lowerCamelCase_       			=   logging.get_logger(__name__)


# General docstring
lowerCamelCase_       			=   '''MobileNetV1Config'''

# Base docstring
lowerCamelCase_       			=   '''google/mobilenet_v1_1.0_224'''
lowerCamelCase_       			=   [1, 1024, 7, 7]

# Image classification docstring
lowerCamelCase_       			=   '''google/mobilenet_v1_1.0_224'''
lowerCamelCase_       			=   '''tabby, tabby cat'''


lowerCamelCase_       			=   [
    '''google/mobilenet_v1_1.0_224''',
    '''google/mobilenet_v1_0.75_192''',
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
]

def        snake_case   (     A__			,A__			,A__=None		):
			UpperCAmelCase_  :				Optional[int]      =      {}

			if isinstance(snake_case_			,snake_case_		):
						UpperCAmelCase_  :				str      =      model.mobilenet_va
			else:
						UpperCAmelCase_  :				Any      =      model

			UpperCAmelCase_  :				List[str]      =      """MobilenetV1/Conv2d_0/"""
			UpperCAmelCase_  :				Dict      =      backbone.conv_stem.convolution.weight
			UpperCAmelCase_  :				Tuple      =      backbone.conv_stem.normalization.bias
			UpperCAmelCase_  :				int      =      backbone.conv_stem.normalization.weight
			UpperCAmelCase_  :				int      =      backbone.conv_stem.normalization.running_mean
			UpperCAmelCase_  :				Tuple      =      backbone.conv_stem.normalization.running_var

			for i in range(13		):
						UpperCAmelCase_  :				Union[str, Any]      =      i + 1
						UpperCAmelCase_  :				Tuple      =      i * 2

						UpperCAmelCase_  :				int      =      backbone.layer[pt_index]
						UpperCAmelCase_  :				List[str]      =      F"""MobilenetV1/Conv2d_{tf_index}_depthwise/"""
						UpperCAmelCase_  :				Optional[int]      =      pointer.convolution.weight
						UpperCAmelCase_  :				int      =      pointer.normalization.bias
						UpperCAmelCase_  :				int      =      pointer.normalization.weight
						UpperCAmelCase_  :				Tuple      =      pointer.normalization.running_mean
						UpperCAmelCase_  :				Any      =      pointer.normalization.running_var

						UpperCAmelCase_  :				List[str]      =      backbone.layer[pt_index + 1]
						UpperCAmelCase_  :				Union[str, Any]      =      F"""MobilenetV1/Conv2d_{tf_index}_pointwise/"""
						UpperCAmelCase_  :				Optional[int]      =      pointer.convolution.weight
						UpperCAmelCase_  :				List[str]      =      pointer.normalization.bias
						UpperCAmelCase_  :				Dict      =      pointer.normalization.weight
						UpperCAmelCase_  :				List[str]      =      pointer.normalization.running_mean
						UpperCAmelCase_  :				str      =      pointer.normalization.running_var

			if isinstance(snake_case_			,snake_case_		):
						UpperCAmelCase_  :				str      =      """MobilenetV1/Logits/Conv2d_1c_1x1/"""
						UpperCAmelCase_  :				Dict      =      model.classifier.weight
						UpperCAmelCase_  :				Optional[Any]      =      model.classifier.bias

			return tf_to_pt_map

def        snake_case   (     A__			,A__			,A__		):
			try:
						import numpy as np
						import tensorflow as tf
			except ImportError:
						logger.error(
						    "Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see "
						    "https://www.tensorflow.org/install/ for installation instructions."		)
						raise

			# Load weights from TF model
			UpperCAmelCase_  :				Optional[Any]      =      tf.train.list_variables(snake_case_		)
			UpperCAmelCase_  :				List[str]      =      {}
			for name, shape in init_vars:
						logger.info(F"""Loading TF weight {name} with shape {shape}"""		)
						UpperCAmelCase_  :				List[Any]      =      tf.train.load_variable(snake_case_			,snake_case_		)
						UpperCAmelCase_  :				Tuple      =      array

			# Build TF to PyTorch weights loading map
			UpperCAmelCase_  :				Any      =      _build_tf_to_pytorch_map(snake_case_			,snake_case_			,snake_case_		)

			for name, pointer in tf_to_pt_map.items():
						logger.info(F"""Importing {name}"""		)
						if name not in tf_weights:
									logger.info(F"""{name} not in tf pre-trained weights, skipping"""		)
									continue

						UpperCAmelCase_  :				Tuple      =      tf_weights[name]

						if "depthwise_weights" in name:
									logger.info("Transposing depthwise"		)
									UpperCAmelCase_  :				Optional[int]      =      np.transpose(snake_case_			,(2, 3, 0, 1)		)
						elif "weights" in name:
									logger.info("Transposing"		)
									if len(pointer.shape		) == 2:  # copying into linear layer
												UpperCAmelCase_  :				Any      =      array.squeeze().transpose()
									else:
												UpperCAmelCase_  :				Optional[int]      =      np.transpose(snake_case_			,(3, 2, 0, 1)		)

						if pointer.shape != array.shape:
									raise ValueError(F"""Pointer shape {pointer.shape} and array shape {array.shape} mismatched"""		)

						logger.info(F"""Initialize PyTorch weight {name} {array.shape}"""		)
						UpperCAmelCase_  :				Optional[int]      =      torch.from_numpy(snake_case_		)

						tf_weights.pop(snake_case_			,snake_case_		)
						tf_weights.pop(name + "/RMSProp"			,snake_case_		)
						tf_weights.pop(name + "/RMSProp_1"			,snake_case_		)
						tf_weights.pop(name + "/ExponentialMovingAverage"			,snake_case_		)

			logger.info(F"""Weights not copied to PyTorch model: {', '.join(tf_weights.keys()		)}"""		)
			return model

def        snake_case   (     A__			,A__		):
			UpperCAmelCase_  :				Tuple      =      features.shape[-2:]
			UpperCAmelCase_  :				Any      =      conv_layer.stride
			UpperCAmelCase_  :				Dict      =      conv_layer.kernel_size

			if in_height % stride_height == 0:
						UpperCAmelCase_  :				Tuple      =      max(kernel_height - stride_height			,0		)
			else:
						UpperCAmelCase_  :				Dict      =      max(kernel_height - (in_height % stride_height)			,0		)

			if in_width % stride_width == 0:
						UpperCAmelCase_  :				Any      =      max(kernel_width - stride_width			,0		)
			else:
						UpperCAmelCase_  :				Tuple      =      max(kernel_width - (in_width % stride_width)			,0		)

			UpperCAmelCase_  :				Dict      =      pad_along_width // 2
			UpperCAmelCase_  :				Any      =      pad_along_width - pad_left
			UpperCAmelCase_  :				Optional[int]      =      pad_along_height // 2
			UpperCAmelCase_  :				Tuple      =      pad_along_height - pad_top

			UpperCAmelCase_  :				List[str]      =      (pad_left, pad_right, pad_top, pad_bottom)
			return nn.functional.pad(snake_case_			,snake_case_			,"constant"			,0.0		)







class     UpperCamelCase_ (nn.Module  ):





	def __init__(   self      :				int			,			lowerCAmelCase_      :				List[Any]			,			lowerCAmelCase_      :				Optional[int]			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				Dict			,			lowerCAmelCase_      :				List[Any] = 1			,			lowerCAmelCase_      :				Optional[Any] = 1			,			lowerCAmelCase_      :				Optional[int] = False			,			lowerCAmelCase_      :				List[str] = True			,			lowerCAmelCase_      :				Union[str, Any] = True			,			)		->    None:
				super().__init__()
				UpperCAmelCase_  :				List[Any]      =      config

				if in_channels % groups != 0:
							raise ValueError(f"""Input channels ({in_channels}) are not divisible by {groups} groups."""		)
				if out_channels % groups != 0:
							raise ValueError(f"""Output channels ({out_channels}) are not divisible by {groups} groups."""		)

				UpperCAmelCase_  :				Tuple      =      0 if config.tf_padding else int((kernel_size - 1) / 2		)

				UpperCAmelCase_  :				List[str]      =      nn.Convad(
				    in_channels=_a			,			out_channels=_a			,			kernel_size=_a			,			stride=_a			,			padding=_a			,			groups=_a			,			bias=_a			,			padding_mode="zeros"			,			)

				if use_normalization:
							UpperCAmelCase_  :				Union[str, Any]      =      nn.BatchNormad(
							    num_features=_a			,			eps=config.layer_norm_eps			,			momentum=0.9_9_9_7			,			affine=_a			,			track_running_stats=_a			,			)
				else:
							UpperCAmelCase_  :				Optional[int]      =      None

				if use_activation:
							if isinstance(_a			,			_a		):
										UpperCAmelCase_  :				List[str]      =      ACTaFN[use_activation]
							elif isinstance(config.hidden_act			,			_a		):
										UpperCAmelCase_  :				List[str]      =      ACTaFN[config.hidden_act]
							else:
										UpperCAmelCase_  :				Optional[int]      =      config.hidden_act
				else:
							UpperCAmelCase_  :				Tuple      =      None





	def   _SCREAMING_SNAKE_CASE   (   self      :				Union[str, Any]			,			lowerCAmelCase_      :				Dict		)		->    torch.Tensor:
				if self.config.tf_padding:
							UpperCAmelCase_  :				Tuple      =      apply_tf_padding(_a			,			self.convolution		)
				UpperCAmelCase_  :				Tuple      =      self.convolution(_a		)
				if self.normalization is not None:
							UpperCAmelCase_  :				Dict      =      self.normalization(_a		)
				if self.activation is not None:
							UpperCAmelCase_  :				str      =      self.activation(_a		)
				return features







class     UpperCamelCase_ (UpperCamelCase__  ):
	__magic_name__			   =       MobileNetVaConfig
	__magic_name__			   =       load_tf_weights_in_mobilenet_va
	__magic_name__			   =       '''mobilenet_v1'''
	__magic_name__			   =       '''pixel_values'''
	__magic_name__			   =       False





	def   _SCREAMING_SNAKE_CASE   (   self      :				Union[str, Any]			,			lowerCAmelCase_      :				Tuple		)		->    None:
				if isinstance(_a			,			(nn.Linear, nn.Convad)		):
							module.weight.data.normal_(mean=0.0			,			std=self.config.initializer_range		)
							if module.bias is not None:
										module.bias.data.zero_()
				elif isinstance(_a			,			nn.BatchNormad		):
							module.bias.data.zero_()
							module.weight.data.fill_(1.0		)





lowerCamelCase_       			=   r'''\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`MobileNetV1Config`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'''

lowerCamelCase_       			=   r'''\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`MobileNetV1ImageProcessor.__call__`] for details.\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.\n'''







@add_start_docstrings(
    '''The bare MobileNetV1 model outputting raw hidden-states without any specific head on top.'''       ,		UpperCamelCase__       ,		)
class     UpperCamelCase_ (UpperCamelCase__  ):





	def __init__(   self      :				str			,			lowerCAmelCase_      :				Optional[int]			,			lowerCAmelCase_      :				Tuple = True		)		->    Union[str, Any]:
				super().__init__(_a		)
				UpperCAmelCase_  :				Any      =      config

				UpperCAmelCase_  :				Optional[int]      =      32
				UpperCAmelCase_  :				str      =      max(int(depth * config.depth_multiplier		)			,			config.min_depth		)

				UpperCAmelCase_  :				List[Any]      =      MobileNetVaConvLayer(
				    _a			,			in_channels=config.num_channels			,			out_channels=_a			,			kernel_size=3			,			stride=2			,			)

				UpperCAmelCase_  :				Dict      =      [1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1]

				UpperCAmelCase_  :				Union[str, Any]      =      nn.ModuleList()
				for i in range(13		):
							UpperCAmelCase_  :				int      =      out_channels

							if strides[i] == 2 or i == 0:
										depth *= 2
										UpperCAmelCase_  :				int      =      max(int(depth * config.depth_multiplier		)			,			config.min_depth		)

							self.layer.append(
							    MobileNetVaConvLayer(
							        _a			,			in_channels=_a			,			out_channels=_a			,			kernel_size=3			,			stride=strides[i]			,			groups=_a			,			)		)

							self.layer.append(
							    MobileNetVaConvLayer(
							        _a			,			in_channels=_a			,			out_channels=_a			,			kernel_size=1			,			)		)

				UpperCAmelCase_  :				Union[str, Any]      =      nn.AdaptiveAvgPoolad((1, 1)		) if add_pooling_layer else None

				# Initialize weights and apply final processing
				self.post_init()





	def   _SCREAMING_SNAKE_CASE   (   self      :				Dict			,			lowerCAmelCase_      :				Dict		)		->    List[Any]:
				raise NotImplementedError





	@add_start_docstrings_to_model_forward(_a		)
	@add_code_sample_docstrings(
	    checkpoint=_CHECKPOINT_FOR_DOC			,			output_type=_a			,			config_class=_CONFIG_FOR_DOC			,			modality="vision"			,			expected_output=_EXPECTED_OUTPUT_SHAPE			,			)
	def   _SCREAMING_SNAKE_CASE   (   self      :				str			,			lowerCAmelCase_      :				Dict = None			,			lowerCAmelCase_      :				Optional[int] = None			,			lowerCAmelCase_      :				Any = None			,			)		->    Union[tuple, BaseModelOutputWithPoolingAndNoAttention]:
				UpperCAmelCase_  :				List[Any]      =      (
				    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
				)
				UpperCAmelCase_  :				Optional[Any]      =      return_dict if return_dict is not None else self.config.use_return_dict

				if pixel_values is None:
							raise ValueError("You have to specify pixel_values"		)

				UpperCAmelCase_  :				str      =      self.conv_stem(_a		)

				UpperCAmelCase_  :				int      =      () if output_hidden_states else None

				for i, layer_module in enumerate(self.layer		):
							UpperCAmelCase_  :				str      =      layer_module(_a		)

							if output_hidden_states:
										UpperCAmelCase_  :				Optional[Any]      =      all_hidden_states + (hidden_states,)

				UpperCAmelCase_  :				Optional[int]      =      hidden_states

				if self.pooler is not None:
							UpperCAmelCase_  :				int      =      torch.flatten(self.pooler(_a		)			,			start_dim=1		)
				else:
							UpperCAmelCase_  :				Dict      =      None

				if not return_dict:
							return tuple(v for v in [last_hidden_state, pooled_output, all_hidden_states] if v is not None		)

				return BaseModelOutputWithPoolingAndNoAttention(
				    last_hidden_state=_a			,			pooler_output=_a			,			hidden_states=_a			,			)







@add_start_docstrings(
    '''\n    MobileNetV1 model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    '''       ,		UpperCamelCase__       ,		)
class     UpperCamelCase_ (UpperCamelCase__  ):





	def __init__(   self      :				List[str]			,			lowerCAmelCase_      :				Any		)		->    None:
				super().__init__(_a		)

				UpperCAmelCase_  :				Optional[Any]      =      config.num_labels
				UpperCAmelCase_  :				Union[str, Any]      =      MobileNetVaModel(_a		)

				UpperCAmelCase_  :				List[str]      =      self.mobilenet_va.layer[-1].convolution.out_channels

				# Classifier head
				UpperCAmelCase_  :				List[Any]      =      nn.Dropout(config.classifier_dropout_prob			,			inplace=_a		)
				UpperCAmelCase_  :				Optional[Any]      =      nn.Linear(_a			,			config.num_labels		) if config.num_labels > 0 else nn.Identity()

				# Initialize weights and apply final processing
				self.post_init()





	@add_start_docstrings_to_model_forward(_a		)
	@add_code_sample_docstrings(
	    checkpoint=_IMAGE_CLASS_CHECKPOINT			,			output_type=_a			,			config_class=_CONFIG_FOR_DOC			,			expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT			,			)
	def   _SCREAMING_SNAKE_CASE   (   self      :				Union[str, Any]			,			lowerCAmelCase_      :				Dict = None			,			lowerCAmelCase_      :				str = None			,			lowerCAmelCase_      :				Tuple = None			,			lowerCAmelCase_      :				str = None			,			)		->    Union[tuple, ImageClassifierOutputWithNoAttention]:
				UpperCAmelCase_  :				Tuple      =      return_dict if return_dict is not None else self.config.use_return_dict

				UpperCAmelCase_  :				Tuple      =      self.mobilenet_va(_a			,			output_hidden_states=_a			,			return_dict=_a		)

				UpperCAmelCase_  :				List[Any]      =      outputs.pooler_output if return_dict else outputs[1]

				UpperCAmelCase_  :				Any      =      self.classifier(self.dropout(_a		)		)

				UpperCAmelCase_  :				str      =      None
				if labels is not None:
							if self.config.problem_type is None:
										if self.num_labels == 1:
													UpperCAmelCase_  :				int      =      """regression"""
										elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
													UpperCAmelCase_  :				Tuple      =      """single_label_classification"""
										else:
													UpperCAmelCase_  :				Optional[Any]      =      """multi_label_classification"""

							if self.config.problem_type == "regression":
										UpperCAmelCase_  :				Any      =      MSELoss()
										if self.num_labels == 1:
													UpperCAmelCase_  :				List[str]      =      loss_fct(logits.squeeze()			,			labels.squeeze()		)
										else:
													UpperCAmelCase_  :				str      =      loss_fct(_a			,			_a		)
							elif self.config.problem_type == "single_label_classification":
										UpperCAmelCase_  :				str      =      CrossEntropyLoss()
										UpperCAmelCase_  :				Any      =      loss_fct(logits.view(-1			,			self.num_labels		)			,			labels.view(-1		)		)
							elif self.config.problem_type == "multi_label_classification":
										UpperCAmelCase_  :				Tuple      =      BCEWithLogitsLoss()
										UpperCAmelCase_  :				Optional[Any]      =      loss_fct(_a			,			_a		)

				if not return_dict:
							UpperCAmelCase_  :				Dict      =      (logits,) + outputs[2:]
							return ((loss,) + output) if loss is not None else output

				return ImageClassifierOutputWithNoAttention(
				    loss=_a			,			logits=_a			,			hidden_states=outputs.hidden_states			,			)











"""simple docstring"""
import copy
import json
import os
import tempfile

from transformers import is_torch_available

from .test_configuration_utils import config_common_kwargs







class     UpperCamelCase_ (__A  ):





	def __init__(   self      :				List[Any]			,			lowerCAmelCase_      :				List[str]			,			lowerCAmelCase_      :				List[Any]=None			,			lowerCAmelCase_      :				List[str]=True			,			lowerCAmelCase_      :				List[Any]=None			,			**lowerCAmelCase_      :				Tuple		)		->    Dict:
				UpperCAmelCase_  :				Tuple      =      parent
				UpperCAmelCase_  :				Optional[int]      =      config_class
				UpperCAmelCase_  :				List[str]      =      has_text_modality
				UpperCAmelCase_  :				Tuple      =      kwargs
				UpperCAmelCase_  :				int      =      common_properties





	def   _SCREAMING_SNAKE_CASE   (   self      :				Union[str, Any]		)		->    Union[str, Any]:
				UpperCAmelCase_  :				Optional[int]      =      self.config_class(**self.inputs_dict		)
				UpperCAmelCase_  :				int      =      (
				    ["hidden_size", "num_attention_heads", "num_hidden_layers"]
				    if self.common_properties is None
				    else self.common_properties
				)

				# Add common fields for text models
				if self.has_text_modality:
							common_properties.extend(["vocab_size"]		)

				# Test that config has the common properties as getters
				for prop in common_properties:
							self.parent.assertTrue(hasattr(lowerCAmelCase_			,			lowerCAmelCase_		)			,			msg=f"""`{prop}` does not exist"""		)

				# Test that config has the common properties as setter
				for idx, name in enumerate(lowerCAmelCase_		):
							try:
										setattr(lowerCAmelCase_			,			lowerCAmelCase_			,			lowerCAmelCase_		)
										self.parent.assertEqual(
										    getattr(lowerCAmelCase_			,			lowerCAmelCase_		)			,			lowerCAmelCase_			,			msg=f"""`{name} value {idx} expected, but was {getattr(lowerCAmelCase_			,			lowerCAmelCase_		)}"""		)
							except NotImplementedError:
										# Some models might not be able to implement setters for common_properties
										# In that case, a NotImplementedError is raised
										pass

        # Test if config class can be called with Config(prop_name=..)
				for idx, name in enumerate(lowerCAmelCase_		):
							try:
										UpperCAmelCase_  :				Optional[Any]      =      self.config_class(**{name: idx}		)
										self.parent.assertEqual(
										    getattr(lowerCAmelCase_			,			lowerCAmelCase_		)			,			lowerCAmelCase_			,			msg=f"""`{name} value {idx} expected, but was {getattr(lowerCAmelCase_			,			lowerCAmelCase_		)}"""		)
							except NotImplementedError:
										# Some models might not be able to implement setters for common_properties
										# In that case, a NotImplementedError is raised
										pass





	def   _SCREAMING_SNAKE_CASE   (   self      :				List[Any]		)		->    Tuple:
				UpperCAmelCase_  :				str      =      self.config_class(**self.inputs_dict		)
				UpperCAmelCase_  :				List[str]      =      json.loads(config.to_json_string()		)
				for key, value in self.inputs_dict.items():
							self.parent.assertEqual(obj[key]			,			lowerCAmelCase_		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[Any]		)		->    Any:
				UpperCAmelCase_  :				Optional[Any]      =      self.config_class(**self.inputs_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							UpperCAmelCase_  :				List[str]      =      os.path.join(lowerCAmelCase_			,			"config.json"		)
							config_first.to_json_file(lowerCAmelCase_		)
							UpperCAmelCase_  :				Dict      =      self.config_class.from_json_file(lowerCAmelCase_		)

				self.parent.assertEqual(config_second.to_dict()			,			config_first.to_dict()		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				List[Any]		)		->    Dict:
				UpperCAmelCase_  :				Any      =      self.config_class(**self.inputs_dict		)

				with tempfile.TemporaryDirectory() as tmpdirname:
							config_first.save_pretrained(lowerCAmelCase_		)
							UpperCAmelCase_  :				Tuple      =      self.config_class.from_pretrained(lowerCAmelCase_		)

				self.parent.assertEqual(config_second.to_dict()			,			config_first.to_dict()		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				int		)		->    Optional[Any]:
				UpperCAmelCase_  :				Any      =      self.config_class(**self.inputs_dict		)

				UpperCAmelCase_  :				int      =      "test"
				with tempfile.TemporaryDirectory() as tmpdirname:
							UpperCAmelCase_  :				Optional[int]      =      os.path.join(lowerCAmelCase_			,			lowerCAmelCase_		)
							config_first.save_pretrained(lowerCAmelCase_		)
							UpperCAmelCase_  :				Union[str, Any]      =      self.config_class.from_pretrained(lowerCAmelCase_			,			subfolder=lowerCAmelCase_		)

				self.parent.assertEqual(config_second.to_dict()			,			config_first.to_dict()		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[Any]		)		->    Tuple:
				UpperCAmelCase_  :				List[str]      =      self.config_class(**self.inputs_dict			,			num_labels=5		)
				self.parent.assertEqual(len(config.idalabel		)			,			5		)
				self.parent.assertEqual(len(config.labelaid		)			,			5		)

				UpperCAmelCase_  :				List[Any]      =      3
				self.parent.assertEqual(len(config.idalabel		)			,			3		)
				self.parent.assertEqual(len(config.labelaid		)			,			3		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				Tuple		)		->    Optional[Any]:
				if self.config_class.is_composition:
							return
				UpperCAmelCase_  :				str      =      self.config_class()
				self.parent.assertIsNotNone(lowerCAmelCase_		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				Dict		)		->    List[str]:
				UpperCAmelCase_  :				Optional[int]      =      copy.deepcopy(lowerCAmelCase_		)
				UpperCAmelCase_  :				Optional[int]      =      self.config_class(**lowerCAmelCase_		)
				UpperCAmelCase_  :				Optional[Any]      =      []
				for key, value in config_common_kwargs.items():
							if key == "torch_dtype":
										if not is_torch_available():
													continue
										else:
													import torch

													if config.torch_dtype != torch.floataa:
																wrong_values.append(("torch_dtype", config.torch_dtype, torch.floataa)		)
							elif getattr(lowerCAmelCase_			,			lowerCAmelCase_		) != value:
										wrong_values.append((key, getattr(lowerCAmelCase_			,			lowerCAmelCase_		), value)		)

				if len(lowerCAmelCase_		) > 0:
							UpperCAmelCase_  :				Any      =      "\n".join([f"""- {v[0]}: got {v[1]} instead of {v[2]}""" for v in wrong_values]		)
							raise ValueError(f"""The following keys were not properly set in the config:\n{errors}"""		)





	def   _SCREAMING_SNAKE_CASE   (   self      :				List[Any]		)		->    str:
				self.create_and_test_config_common_properties()
				self.create_and_test_config_to_json_string()
				self.create_and_test_config_to_json_file()
				self.create_and_test_config_from_and_save_pretrained()
				self.create_and_test_config_from_and_save_pretrained_subfolder()
				self.create_and_test_config_with_num_labels()
				self.check_config_can_be_init_without_params()
				self.check_config_arguments_init()



