

"""simple docstring"""







import collections
import inspect
import unittest

from transformers import FocalNetConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch
       from torch import nn

       from transformers import (
           FocalNetBackbone,
           FocalNetForImageClassification,
           FocalNetForMaskedImageModeling,
           FocalNetModel,
       )
       from transformers.models.focalnet.modeling_focalnet import FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
       from PIL import Image

       from transformers import AutoImageProcessor







class  UpperCamelCase	:
   def __init__(    self  ,__UpperCamelCase  ,__UpperCamelCase=13  ,__UpperCamelCase=32  ,__UpperCamelCase=2  ,__UpperCamelCase=3  ,__UpperCamelCase=16  ,__UpperCamelCase=[32, 64, 128]  ,__UpperCamelCase=[1, 2, 1]  ,__UpperCamelCase=[2, 2, 4]  ,__UpperCamelCase=2  ,__UpperCamelCase=2.0  ,__UpperCamelCase=True  ,__UpperCamelCase=0.0  ,__UpperCamelCase=0.0  ,__UpperCamelCase=0.1  ,__UpperCamelCase="gelu"  ,__UpperCamelCase=False  ,__UpperCamelCase=True  ,__UpperCamelCase=0.02  ,__UpperCamelCase=1e-5  ,__UpperCamelCase=True  ,__UpperCamelCase=None  ,__UpperCamelCase=True  ,__UpperCamelCase=10  ,__UpperCamelCase=8  ,__UpperCamelCase=["stage1", "stage2"]  ,__UpperCamelCase=[1, 2]  ,)			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       Union[str, Any]									=			parent
        lowercase_			:       Dict									=			batch_size
        lowercase_			:       Optional[Any]									=			image_size
        lowercase_			:       Tuple									=			patch_size
        lowercase_			:       Any									=			num_channels
        lowercase_			:       Tuple									=			embed_dim
        lowercase_			:       List[str]									=			hidden_sizes
        lowercase_			:       Optional[int]									=			depths
        lowercase_			:       Dict									=			num_heads
        lowercase_			:       Optional[int]									=			window_size
        lowercase_			:       Tuple									=			mlp_ratio
        lowercase_			:       Union[str, Any]									=			qkv_bias
        lowercase_			:       Union[str, Any]									=			hidden_dropout_prob
        lowercase_			:       Optional[Any]									=			attention_probs_dropout_prob
        lowercase_			:       int									=			drop_path_rate
        lowercase_			:       List[str]									=			hidden_act
        lowercase_			:       str									=			use_absolute_embeddings
        lowercase_			:       List[Any]									=			patch_norm
        lowercase_			:       str									=			layer_norm_eps
        lowercase_			:       Tuple									=			initializer_range
        lowercase_			:       Dict									=			is_training
        lowercase_			:       Any									=			scope
        lowercase_			:       Optional[int]									=			use_labels
        lowercase_			:       List[Any]									=			type_sequence_label_size
        lowercase_			:       Union[str, Any]									=			encoder_stride
        lowercase_			:       int									=			out_features
        lowercase_			:       int									=			out_indices
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        lowercase_			:       str									=			floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

        lowercase_			:       Optional[Any]									=			None
        if self.use_labels:
             lowercase_			:       List[str]									=			ids_tensor([self.batch_size]  ,self.type_sequence_label_size    )

        lowercase_			:       Optional[Any]									=			self.get_config()

        return config, pixel_values, labels
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        return FocalNetConfig(
            image_size=self.image_size  ,patch_size=self.patch_size  ,num_channels=self.num_channels  ,embed_dim=self.embed_dim  ,hidden_sizes=self.hidden_sizes  ,depths=self.depths  ,num_heads=self.num_heads  ,window_size=self.window_size  ,mlp_ratio=self.mlp_ratio  ,qkv_bias=self.qkv_bias  ,hidden_dropout_prob=self.hidden_dropout_prob  ,attention_probs_dropout_prob=self.attention_probs_dropout_prob  ,drop_path_rate=self.drop_path_rate  ,hidden_act=self.hidden_act  ,use_absolute_embeddings=self.use_absolute_embeddings  ,path_norm=self.patch_norm  ,layer_norm_eps=self.layer_norm_eps  ,initializer_range=self.initializer_range  ,encoder_stride=self.encoder_stride  ,out_features=self.out_features  ,out_indices=self.out_indices  ,)
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   Optional[Any]:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			FocalNetModel(config=__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()
        lowercase_			:       int									=			model(__UpperCamelCase    )

        lowercase_			:       Optional[int]									=			((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths    ) - 1))
        lowercase_			:       Optional[Any]									=			int(config.embed_dim * 2 ** (len(config.depths    ) - 1)    )

        self.parent.assertEqual(result.last_hidden_state.shape  ,(self.batch_size, expected_seq_len, expected_dim)    )
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   Union[str, Any]:


        '''simple docstring'''


        lowercase_			:       Optional[Any]									=			FocalNetBackbone(config=__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()
        lowercase_			:       Union[str, Any]									=			model(__UpperCamelCase    )

        # verify feature maps
        self.parent.assertEqual(len(result.feature_maps    )  ,len(config.out_features    )    )
        self.parent.assertListEqual(list(result.feature_maps[0].shape    )  ,[self.batch_size, self.image_size, 8, 8]    )

        # verify channels
        self.parent.assertEqual(len(model.channels    )  ,len(config.out_features    )    )
        self.parent.assertListEqual(model.channels  ,config.hidden_sizes[:-1]    )

        # verify backbone works with out_features=None
        lowercase_			:       int									=			None
        lowercase_			:       Tuple									=			FocalNetBackbone(config=__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()
        lowercase_			:       Optional[Any]									=			model(__UpperCamelCase    )

        # verify feature maps
        self.parent.assertEqual(len(result.feature_maps    )  ,1    )
        self.parent.assertListEqual(list(result.feature_maps[0].shape    )  ,[self.batch_size, self.image_size * 2, 4, 4]    )

        # verify channels
        self.parent.assertEqual(len(model.channels    )  ,1    )
        self.parent.assertListEqual(model.channels  ,[config.hidden_sizes[-1]]    )
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   Optional[Any]:


        '''simple docstring'''


        lowercase_			:       int									=			FocalNetForMaskedImageModeling(config=__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()
        lowercase_			:       Any									=			model(__UpperCamelCase    )
        self.parent.assertEqual(
            result.reconstruction.shape  ,(self.batch_size, self.num_channels, self.image_size, self.image_size)    )

        # test greyscale images
        lowercase_			:       Dict									=			1
        lowercase_			:       Union[str, Any]									=			FocalNetForMaskedImageModeling(__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()

        lowercase_			:       str									=			floats_tensor([self.batch_size, 1, self.image_size, self.image_size]    )
        lowercase_			:       Dict									=			model(__UpperCamelCase    )
        self.parent.assertEqual(result.reconstruction.shape  ,(self.batch_size, 1, self.image_size, self.image_size)    )
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   Any:


        '''simple docstring'''


        lowercase_			:       Union[str, Any]									=			self.type_sequence_label_size
        lowercase_			:       Tuple									=			FocalNetForImageClassification(__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()
        lowercase_			:       Dict									=			model(__UpperCamelCase  ,labels=__UpperCamelCase    )
        self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.type_sequence_label_size)    )

        # test greyscale images
        lowercase_			:       Optional[int]									=			1
        lowercase_			:       str									=			FocalNetForImageClassification(__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()

        lowercase_			:       str									=			floats_tensor([self.batch_size, 1, self.image_size, self.image_size]    )
        lowercase_			:       Tuple									=			model(__UpperCamelCase    )
        self.parent.assertEqual(result.logits.shape  ,(self.batch_size, self.type_sequence_label_size)    )







   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        lowercase_			:       Dict									=			self.prepare_config_and_inputs()

        lowercase_			:       Optional[Any]									=			config_and_inputs
        lowercase_			:       Dict									=			{'pixel_values': pixel_values}
        return config, inputs_dict







@require_torch
class  UpperCamelCase	(    lowercase_		,   lowercase_		,   unittest.TestCase						):
   lowercase							=						(
       (
           FocalNetModel,
           FocalNetForImageClassification,
           FocalNetForMaskedImageModeling,
           FocalNetBackbone,
       )
       if is_torch_available()
       else ()
   )
   lowercase							=						(
       {'feature-extraction': FocalNetModel, 'image-classification': FocalNetForImageClassification}
       if is_torch_available()
       else {}
   )
   lowercase							=						False

   lowercase							=						False
   lowercase							=						False
   lowercase							=						False
   lowercase							=						False
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        lowercase_			:       Union[str, Any]									=			FocalNetModelTester(self    )
        lowercase_			:       List[Any]									=			ConfigTester(self  ,config_class=__UpperCamelCase  ,embed_dim=37  ,has_text_modality=__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        self.create_and_test_config_common_properties()
        self.config_tester.create_and_test_config_to_json_string()
        self.config_tester.create_and_test_config_to_json_file()
        self.config_tester.create_and_test_config_from_and_save_pretrained()
        self.config_tester.create_and_test_config_with_num_labels()
        self.config_tester.check_config_can_be_init_without_params()
        self.config_tester.check_config_arguments_init()
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        return
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        lowercase_			:       List[str]									=			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        lowercase_			:       Optional[Any]									=			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_backbone(*__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   List[str]:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_masked_image_modeling(*__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        lowercase_			:       int									=			self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_image_classification(*__UpperCamelCase    )
   @unittest.skip(reason='FocalNet does not use inputs_embeds'    )
   def     _UpperCAmelCase     (    self    )			->   Tuple:


        '''simple docstring'''


        pass
   @unittest.skip(reason='FocalNet does not use feedforward chunking'    )
   def     _UpperCAmelCase     (    self    )			->   Union[str, Any]:


        '''simple docstring'''


        pass
   def     _UpperCAmelCase     (    self    )			->   int:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes[:-1]:
             lowercase_			:       Any									=			model_class(__UpperCamelCase    )
             self.assertIsInstance(model.get_input_embeddings()  ,(nn.Module)    )
             lowercase_			:       Union[str, Any]									=			model.get_output_embeddings()
             self.assertTrue(x is None or isinstance(__UpperCamelCase  ,nn.Linear    )    )
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        lowercase_			:       int									=			self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes[:-1]:
             lowercase_			:       List[Any]									=			model_class(__UpperCamelCase    )
             lowercase_			:       List[Any]									=			inspect.signature(model.forward    )
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             lowercase_			:       int									=			[*signature.parameters.keys()]

             lowercase_			:       Optional[int]									=			['pixel_values']
             self.assertListEqual(arg_names[:1]  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )			->   List[str]:


        '''simple docstring'''


        lowercase_			:       Optional[int]									=			model_class(__UpperCamelCase    )
        model.to(__UpperCamelCase    )
        model.eval()

        with torch.no_grad():
             lowercase_			:       Any									=			model(**self._prepare_for_class(__UpperCamelCase  ,__UpperCamelCase    )    )

        lowercase_			:       Tuple									=			outputs.hidden_states

        lowercase_			:       int									=			getattr(
            self.model_tester  ,'expected_num_hidden_layers'  ,len(self.model_tester.depths    ) + 1    )
        self.assertEqual(len(__UpperCamelCase    )  ,__UpperCamelCase    )

        # FocalNet has a different seq_length
        lowercase_			:       Optional[Any]									=			(
            config.patch_size
            if isinstance(config.patch_size  ,collections.abc.Iterable    )
            else (config.patch_size, config.patch_size)
        )

        lowercase_			:       Optional[Any]									=			(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

        self.assertListEqual(
            list(hidden_states[0].shape[-2:]    )  ,[num_patches, self.model_tester.embed_dim]  ,)

        lowercase_			:       Optional[Any]									=			outputs.reshaped_hidden_states
        self.assertEqual(len(__UpperCamelCase    )  ,__UpperCamelCase    )

        lowercase_			:       Any									=			reshaped_hidden_states[0].shape
        lowercase_			:       int									=			(
            reshaped_hidden_states[0].view(__UpperCamelCase  ,__UpperCamelCase  ,height * width    ).permute(0  ,2  ,1    )
        )
        self.assertListEqual(
            list(reshaped_hidden_states.shape[-2:]    )  ,[num_patches, self.model_tester.embed_dim]  ,)
   def     _UpperCAmelCase     (    self    )			->   Union[str, Any]:


        '''simple docstring'''


        lowercase_			:       int									=			self.model_tester.prepare_config_and_inputs_for_common()

        lowercase_			:       str									=			(
            self.model_tester.image_size
            if isinstance(self.model_tester.image_size  ,collections.abc.Iterable    )
            else (self.model_tester.image_size, self.model_tester.image_size)
        )

        for model_class in self.all_model_classes[:-1]:
             lowercase_			:       List[Any]									=			True
             self.check_hidden_states_output(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )

             # check that output_hidden_states also work using config
             del inputs_dict["output_hidden_states"]
             lowercase_			:       Optional[Any]									=			True

             self.check_hidden_states_output(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase    )
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        lowercase_			:       str									=			self.model_tester.prepare_config_and_inputs_for_common()
        lowercase_			:       Dict									=			3

        lowercase_			:       Optional[Any]									=			(
            self.model_tester.image_size
            if isinstance(self.model_tester.image_size  ,collections.abc.Iterable    )
            else (self.model_tester.image_size, self.model_tester.image_size)
        )
        lowercase_			:       Tuple									=			(
            config.patch_size
            if isinstance(config.patch_size  ,collections.abc.Iterable    )
            else (config.patch_size, config.patch_size)
        )

        lowercase_			:       Optional[int]									=			image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
        lowercase_			:       Optional[int]									=			image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

        for model_class in self.all_model_classes[:-1]:
             lowercase_			:       Any									=			True
             self.check_hidden_states_output(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,(padded_height, padded_width)    )

             # check that output_hidden_states also work using config
             del inputs_dict["output_hidden_states"]
             lowercase_			:       List[str]									=			True
             self.check_hidden_states_output(__UpperCamelCase  ,__UpperCamelCase  ,__UpperCamelCase  ,(padded_height, padded_width)    )
   @slow
   def     _UpperCAmelCase     (    self    )			->   List[Any]:


        '''simple docstring'''


        for model_name in FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             lowercase_			:       Optional[Any]									=			FocalNetModel.from_pretrained(__UpperCamelCase    )
             self.assertIsNotNone(__UpperCamelCase    )







   def     _UpperCAmelCase     (    self    )			->   Optional[int]:


        '''simple docstring'''


        lowercase_			:       List[Any]									=			self.model_tester.prepare_config_and_inputs_for_common()

        lowercase_			:       List[Any]									=			_config_zero_init(__UpperCamelCase    )
        for model_class in self.all_model_classes:
             lowercase_			:       Tuple									=			model_class(config=__UpperCamelCase    )
             for name, param in model.named_parameters():
                  if "embeddings" not in name and param.requires_grad:
                       self.assertIn(
                           ((param.data.mean() * 1e9).round() / 1e9).item()  ,[0.0, 1.0]  ,msg=f'''Parameter {name} of model {model_class} seems not properly initialized'''  ,)







@require_vision
@require_torch
class  UpperCamelCase	(    unittest.TestCase						):
   @cached_property
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        return AutoImageProcessor.from_pretrained('microsoft/focalnet-tiny'    ) if is_vision_available() else None







   @slow
   def     _UpperCAmelCase     (    self    )			->   Optional[Any]:


        '''simple docstring'''


        lowercase_			:       int									=			FocalNetForImageClassification.from_pretrained('microsoft/focalnet-tiny'    ).to(__UpperCamelCase    )
        lowercase_			:       Any									=			self.default_image_processor

        lowercase_			:       Union[str, Any]									=			Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'    )
        lowercase_			:       int									=			image_processor(images=__UpperCamelCase  ,return_tensors='pt'    ).to(__UpperCamelCase    )

        # forward pass
        with torch.no_grad():
             lowercase_			:       Optional[int]									=			model(**__UpperCamelCase    )

        # verify the logits
        lowercase_			:       int									=			torch.Size((1, 1000)    )
        self.assertEqual(outputs.logits.shape  ,__UpperCamelCase    )
        lowercase_			:       Optional[int]									=			torch.tensor([0.2166, -0.4368, 0.2191]    ).to(__UpperCamelCase    )
        self.assertTrue(torch.allclose(outputs.logits[0, :3]  ,__UpperCamelCase  ,atol=1e-4    )    )
        self.assertTrue(outputs.logits.argmax(dim=-1    ).item()  ,281    )







@require_torch
class  UpperCamelCase	(    lowercase_		,   unittest.TestCase						):
   lowercase							=						(FocalNetBackbone,) if is_torch_available() else ()
   lowercase							=						FocalNetConfig

   lowercase							=						False
   def     _UpperCAmelCase     (    self    )			->   Any:


        '''simple docstring'''


        lowercase_			:       Union[str, Any]									=			FocalNetModelTester(self    )


"""simple docstring"""







import functools
import operator

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


__SCREAMING_SNAKE_CASE								=logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE								={
    "facebook/wav2vec2-base-960h": "https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json",
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}







class  UpperCamelCase	(    lowercase_						):
   lowercase							=						'wav2vec2'
   def __init__(    self  ,__UpperCamelCase=32  ,__UpperCamelCase=768  ,__UpperCamelCase=12  ,__UpperCamelCase=12  ,__UpperCamelCase=3072  ,__UpperCamelCase="gelu"  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.0  ,__UpperCamelCase=0.0  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.1  ,__UpperCamelCase=0.02  ,__UpperCamelCase=1e-5  ,__UpperCamelCase="group"  ,__UpperCamelCase="gelu"  ,__UpperCamelCase=(512, 512, 512, 512, 512, 512, 512)  ,__UpperCamelCase=(5, 2, 2, 2, 2, 2, 2)  ,__UpperCamelCase=(10, 3, 3, 3, 3, 2, 2)  ,__UpperCamelCase=False  ,__UpperCamelCase=128  ,__UpperCamelCase=16  ,__UpperCamelCase=False  ,__UpperCamelCase=True  ,__UpperCamelCase=0.05  ,__UpperCamelCase=10  ,__UpperCamelCase=2  ,__UpperCamelCase=0.0  ,__UpperCamelCase=10  ,__UpperCamelCase=0  ,__UpperCamelCase=320  ,__UpperCamelCase=2  ,__UpperCamelCase=0.1  ,__UpperCamelCase=100  ,__UpperCamelCase=256  ,__UpperCamelCase=256  ,__UpperCamelCase=0.1  ,__UpperCamelCase="sum"  ,__UpperCamelCase=False  ,__UpperCamelCase=False  ,__UpperCamelCase=256  ,__UpperCamelCase=(512, 512, 512, 512, 1500)  ,__UpperCamelCase=(5, 3, 3, 1, 1)  ,__UpperCamelCase=(1, 2, 3, 1, 1)  ,__UpperCamelCase=512  ,__UpperCamelCase=0  ,__UpperCamelCase=1  ,__UpperCamelCase=2  ,__UpperCamelCase=False  ,__UpperCamelCase=3  ,__UpperCamelCase=2  ,__UpperCamelCase=3  ,__UpperCamelCase=None  ,__UpperCamelCase=None  ,**__UpperCamelCase  ,)			->   Optional[Any]:


        '''simple docstring'''


        super().__init__(**__UpperCamelCase  ,pad_token_id=__UpperCamelCase  ,bos_token_id=__UpperCamelCase  ,eos_token_id=__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			hidden_size
        lowercase_			:       Tuple									=			feat_extract_norm
        lowercase_			:       Dict									=			feat_extract_activation
        lowercase_			:       List[str]									=			list(__UpperCamelCase    )
        lowercase_			:       str									=			list(__UpperCamelCase    )
        lowercase_			:       Dict									=			list(__UpperCamelCase    )
        lowercase_			:       Optional[Any]									=			conv_bias
        lowercase_			:       Dict									=			num_conv_pos_embeddings
        lowercase_			:       List[str]									=			num_conv_pos_embedding_groups
        lowercase_			:       Optional[Any]									=			len(self.conv_dim    )
        lowercase_			:       Any									=			num_hidden_layers
        lowercase_			:       List[Any]									=			intermediate_size
        lowercase_			:       List[Any]									=			hidden_act
        lowercase_			:       Optional[int]									=			num_attention_heads
        lowercase_			:       int									=			hidden_dropout
        lowercase_			:       Dict									=			attention_dropout
        lowercase_			:       Union[str, Any]									=			activation_dropout
        lowercase_			:       Tuple									=			feat_proj_dropout
        lowercase_			:       List[str]									=			final_dropout
        lowercase_			:       Union[str, Any]									=			layerdrop
        lowercase_			:       List[str]									=			layer_norm_eps
        lowercase_			:       Optional[int]									=			initializer_range
        lowercase_			:       List[Any]									=			vocab_size
        lowercase_			:       Optional[int]									=			do_stable_layer_norm
        lowercase_			:       Union[str, Any]									=			use_weighted_layer_sum

        if (
            (len(self.conv_stride    ) != self.num_feat_extract_layers)
            or (len(self.conv_kernel    ) != self.num_feat_extract_layers)
            or (len(self.conv_dim    ) != self.num_feat_extract_layers)
        ):
             raise ValueError(
                 'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
                 ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
                 f''' {len(self.conv_dim    )}`, `len(config.conv_stride) = {len(self.conv_stride    )}`,'''
                 f''' `len(config.conv_kernel) = {len(self.conv_kernel    )}`.'''    )

        # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
        lowercase_			:       Dict									=			apply_spec_augment
        lowercase_			:       Optional[int]									=			mask_time_prob
        lowercase_			:       Union[str, Any]									=			mask_time_length
        lowercase_			:       List[str]									=			mask_time_min_masks
        lowercase_			:       List[str]									=			mask_feature_prob
        lowercase_			:       Any									=			mask_feature_length
        lowercase_			:       List[Any]									=			mask_feature_min_masks

        # parameters for pretraining with codevector quantized representations
        lowercase_			:       List[Any]									=			num_codevectors_per_group
        lowercase_			:       Optional[int]									=			num_codevector_groups
        lowercase_			:       Dict									=			contrastive_logits_temperature
        lowercase_			:       int									=			feat_quantizer_dropout
        lowercase_			:       Optional[int]									=			num_negatives
        lowercase_			:       str									=			codevector_dim
        lowercase_			:       str									=			proj_codevector_dim
        lowercase_			:       Optional[Any]									=			diversity_loss_weight

        # ctc loss
        lowercase_			:       Tuple									=			ctc_loss_reduction
        lowercase_			:       int									=			ctc_zero_infinity

        # adapter
        lowercase_			:       int									=			add_adapter
        lowercase_			:       Dict									=			adapter_kernel_size
        lowercase_			:       List[str]									=			adapter_stride
        lowercase_			:       Dict									=			num_adapter_layers
        lowercase_			:       Dict									=			output_hidden_size or hidden_size
        lowercase_			:       Optional[Any]									=			adapter_attn_dim

        # SequenceClassification-specific parameter. Feel free to ignore for other classes.
        lowercase_			:       Dict									=			classifier_proj_size

        # XVector-specific parameters. Feel free to ignore for other classes.
        lowercase_			:       Any									=			list(__UpperCamelCase    )
        lowercase_			:       str									=			list(__UpperCamelCase    )
        lowercase_			:       Any									=			list(__UpperCamelCase    )
        lowercase_			:       Tuple									=			xvector_output_dim







   @property
   def     _UpperCAmelCase     (    self    )			->   str:


        '''simple docstring'''


        return functools.reduce(operator.mul  ,self.conv_stride  ,1    )

