





from __future__ import annotations

import copy
import inspect
import unittest

import numpy as np

from transformers import is_tf_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
    import tensorflow as tf

    from transformers import (
        TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
        TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
        TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
        TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
        TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
        LayoutLMvaConfig,
        TFLayoutLMvaForQuestionAnswering,
        TFLayoutLMvaForSequenceClassification,
        TFLayoutLMvaForTokenClassification,
        TFLayoutLMvaModel,
    )

if is_vision_available():
    from PIL import Image

    from transformers import LayoutLMvaImageProcessor

class 		SCREAMING_SNAKE_CASE__    :


      def __init__(self	:				int    ,      a__	:				Any    ,      a__	:				Optional[int]=2    ,      a__	:				List[str]=3    ,      a__	:				Optional[int]=4    ,      a__	:				Dict=2    ,      a__	:				List[Any]=7    ,      a__	:				str=True    ,      a__	:				int=True    ,      a__	:				str=True    ,      a__	:				Union[str, Any]=True    ,      a__	:				Dict=99    ,      a__	:				Optional[Any]=36    ,      a__	:				int=2    ,      a__	:				List[str]=4    ,      a__	:				List[str]=37    ,      a__	:				List[Any]="gelu"    ,      a__	:				List[str]=0.1    ,      a__	:				Optional[Any]=0.1    ,      a__	:				Dict=512    ,      a__	:				Dict=16    ,      a__	:				Optional[Any]=2    ,      a__	:				str=0.0_2    ,      a__	:				Optional[Any]=6    ,      a__	:				Tuple=6    ,      a__	:				List[Any]=3    ,      a__	:				Optional[int]=4    ,      a__	:				Optional[int]=None    ,      a__	:				List[Any]=1000    ,      ):





         """simple docstring"""



         __snake_case								=       parent
         __snake_case								=       batch_size
         __snake_case								=       num_channels
         __snake_case								=       image_size
         __snake_case								=       patch_size
         __snake_case								=       is_training
         __snake_case								=       use_input_mask
         __snake_case								=       use_token_type_ids
         __snake_case								=       use_labels
         __snake_case								=       vocab_size
         __snake_case								=       hidden_size
         __snake_case								=       num_hidden_layers
         __snake_case								=       num_attention_heads
         __snake_case								=       intermediate_size
         __snake_case								=       hidden_act
         __snake_case								=       hidden_dropout_prob
         __snake_case								=       attention_probs_dropout_prob
         __snake_case								=       max_position_embeddings
         __snake_case								=       type_vocab_size
         __snake_case								=       type_sequence_label_size
         __snake_case								=       initializer_range
         __snake_case								=       coordinate_size
         __snake_case								=       shape_size
         __snake_case								=       num_labels
         __snake_case								=       num_choices
         __snake_case								=       scope
         __snake_case								=       range_bbox

         # LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
         __snake_case								=       text_seq_length
         __snake_case								=       (image_size // patch_size) ** 2 + 1
         __snake_case								=       self.text_seq_length + self.image_seq_length


      def        a			(self	:				List[str]				):





         """simple docstring"""



         __snake_case								=       ids_tensor([self.batch_size, self.text_seq_length]    ,      self.vocab_size				)

         __snake_case								=       ids_tensor([self.batch_size, self.text_seq_length, 4]    ,      self.range_bbox				)
         __snake_case								=       bbox.numpy()
         # Ensure that bbox is legal
         for i in range(bbox.shape[0]				):
            for j in range(bbox.shape[1]				):
               if bbox[i, j, 3] < bbox[i, j, 1]:
                  __snake_case								=       bbox[i, j, 3]
                  __snake_case								=       bbox[i, j, 1]
                  __snake_case								=       tmp_coordinate
               if bbox[i, j, 2] < bbox[i, j, 0]:
                  __snake_case								=       bbox[i, j, 2]
                  __snake_case								=       bbox[i, j, 0]
                  __snake_case								=       tmp_coordinate
         __snake_case								=       tf.constant(a__				)

         __snake_case								=       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

         __snake_case								=       None
         if self.use_input_mask:
            __snake_case								=       random_attention_mask([self.batch_size, self.text_seq_length]				)

         __snake_case								=       None
         if self.use_token_type_ids:
            __snake_case								=       ids_tensor([self.batch_size, self.text_seq_length]    ,      self.type_vocab_size				)

         __snake_case								=       None
         __snake_case								=       None
         if self.use_labels:
            __snake_case								=       ids_tensor([self.batch_size]    ,      self.type_sequence_label_size				)
            __snake_case								=       ids_tensor([self.batch_size, self.text_seq_length]    ,      self.num_labels				)

         __snake_case								=       LayoutLMvaConfig(
             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    ,      coordinate_size=self.coordinate_size    ,      shape_size=self.shape_size    ,      input_size=self.image_size    ,      patch_size=self.patch_size    ,      )

         return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels


      def        a			(self	:				List[str]    ,      a__	:				Any    ,      a__	:				Any    ,      a__	:				Union[str, Any]    ,      a__	:				Optional[int]    ,      a__	:				List[str]    ,      a__	:				int				):





         """simple docstring"""



         __snake_case								=       TFLayoutLMvaModel(config=a__				)

         # text + image
         __snake_case								=       model(a__    ,      pixel_values=a__    ,      training=a__				)
         __snake_case								=       model(
             a__    ,      bbox=a__    ,      pixel_values=a__    ,      attention_mask=a__    ,      token_type_ids=a__    ,      training=a__    ,      )
         __snake_case								=       model(a__    ,      bbox=a__    ,      pixel_values=a__    ,      training=a__				)

         self.parent.assertEqual(result.last_hidden_state.shape    ,      (self.batch_size, self.seq_length, self.hidden_size)				)

         # text only
         __snake_case								=       model(a__    ,      training=a__				)
         self.parent.assertEqual(
             result.last_hidden_state.shape    ,      (self.batch_size, self.text_seq_length, self.hidden_size)				)

         # image only
         __snake_case								=       model({'''pixel_values''': pixel_values}    ,      training=a__				)
         self.parent.assertEqual(
             result.last_hidden_state.shape    ,      (self.batch_size, self.image_seq_length, self.hidden_size)				)


      def        a			(self	:				Dict    ,      a__	:				Any    ,      a__	:				List[Any]    ,      a__	:				Tuple    ,      a__	:				Any    ,      a__	:				Any    ,      a__	:				Optional[int]    ,      a__	:				Optional[int]				):





         """simple docstring"""



         __snake_case								=       self.num_labels
         __snake_case								=       TFLayoutLMvaForSequenceClassification(config=a__				)
         __snake_case								=       model(
             a__    ,      bbox=a__    ,      pixel_values=a__    ,      attention_mask=a__    ,      token_type_ids=a__    ,      labels=a__    ,      training=a__    ,      )
         self.parent.assertEqual(result.logits.shape    ,      (self.batch_size, self.num_labels)				)


      def        a			(self	:				Optional[int]    ,      a__	:				str    ,      a__	:				List[str]    ,      a__	:				Tuple    ,      a__	:				Tuple    ,      a__	:				List[str]    ,      a__	:				List[Any]    ,      a__	:				int				):





         """simple docstring"""



         __snake_case								=       self.num_labels
         __snake_case								=       TFLayoutLMvaForTokenClassification(config=a__				)
         __snake_case								=       model(
             a__    ,      bbox=a__    ,      pixel_values=a__    ,      attention_mask=a__    ,      token_type_ids=a__    ,      labels=a__    ,      training=a__    ,      )
         self.parent.assertEqual(result.logits.shape    ,      (self.batch_size, self.text_seq_length, self.num_labels)				)


      def        a			(self	:				Union[str, Any]    ,      a__	:				List[Any]    ,      a__	:				List[str]    ,      a__	:				str    ,      a__	:				Union[str, Any]    ,      a__	:				int    ,      a__	:				List[str]    ,      a__	:				str				):





         """simple docstring"""



         __snake_case								=       2
         __snake_case								=       TFLayoutLMvaForQuestionAnswering(config=a__				)
         __snake_case								=       model(
             a__    ,      bbox=a__    ,      pixel_values=a__    ,      attention_mask=a__    ,      token_type_ids=a__    ,      start_positions=a__    ,      end_positions=a__    ,      training=a__    ,      )
         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        a			(self	:				Any				):





         """simple docstring"""



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






@require_tf
class 		SCREAMING_SNAKE_CASE__    (	_UpperCAmelCase						,				_UpperCAmelCase						,				unittest.TestCase  ):
      A_						:    str							=   (
          (
              TFLayoutLMvaModel,
              TFLayoutLMvaForQuestionAnswering,
              TFLayoutLMvaForSequenceClassification,
              TFLayoutLMvaForTokenClassification,
          )
          if is_tf_available()
          else ()
      )
      A_						:    List[Any]							=   (
          {'document-question-answering': TFLayoutLMvaForQuestionAnswering, 'feature-extraction': TFLayoutLMvaModel}
          if is_tf_available()
          else {}
      )

      A_						:    Union[str, Any]							=   False
      A_						:    int							=   False
      A_						:    Optional[int]							=   False


      def        a			(self	:				str    ,      a__	:				Tuple    ,      a__	:				Tuple    ,      a__	:				Tuple    ,      a__	:				Tuple    ,      a__	:				Optional[int]				):





         """simple docstring"""



         return True


      def        a			(self	:				Union[str, Any]    ,      a__	:				Union[str, Any]    ,      a__	:				Optional[int]    ,      a__	:				str=False				):





         """simple docstring"""



         __snake_case								=       copy.deepcopy(a__				)

         if model_class in get_values(a__				):
            __snake_case								=       {
                k: tf.tile(tf.expand_dims(a__    ,      1				)    ,      (1, self.model_tester.num_choices) + (1,) * (v.ndim - 1)				)
                if isinstance(a__    ,      tf.Tensor				) and v.ndim > 0
                else v
                for k, v in inputs_dict.items()
            }

         if return_labels:
            if model_class in get_values(a__				):
               __snake_case								=       tf.ones(self.model_tester.batch_size    ,      dtype=tf.intaa				)
            elif model_class in get_values(a__				):
               __snake_case								=       tf.zeros(self.model_tester.batch_size    ,      dtype=tf.intaa				)
               __snake_case								=       tf.zeros(self.model_tester.batch_size    ,      dtype=tf.intaa				)
            elif model_class in get_values(a__				):
               __snake_case								=       tf.zeros(self.model_tester.batch_size    ,      dtype=tf.intaa				)
            elif model_class in get_values(a__				):
               __snake_case								=       tf.zeros(
                   (self.model_tester.batch_size, self.model_tester.text_seq_length)    ,      dtype=tf.intaa				)

         return inputs_dict


      def        a			(self	:				Any				):





         """simple docstring"""



         __snake_case								=       TFLayoutLMvaModelTester(self				)
         __snake_case								=       ConfigTester(self    ,      config_class=a__    ,      hidden_size=37				)


      def        a			(self	:				Optional[Any]				):





         """simple docstring"""



         self.config_tester.run_common_tests()


      def        a			(self	:				List[Any]				):





         """simple docstring"""



         __snake_case	,     __snake_case								=       self.model_tester.prepare_config_and_inputs_for_common()
         for model_class in self.all_model_classes:
            __snake_case								=       model_class(a__				)
            if getattr(a__    ,      '''hf_compute_loss'''    ,      a__				):
               # The number of elements in the loss should be the same as the number of elements in the label
               __snake_case								=       self._prepare_for_class(inputs_dict.copy()    ,      a__    ,      return_labels=a__				)
               __snake_case								=       prepared_for_class[
                   sorted(prepared_for_class.keys() - inputs_dict.keys()    ,      reverse=a__				)[0]
               ]
               __snake_case								=       added_label.shape.as_list()[:1]

               # Test that model correctly compute the loss with kwargs
               __snake_case								=       self._prepare_for_class(inputs_dict.copy()    ,      a__    ,      return_labels=a__				)
               __snake_case								=       prepared_for_class.pop('''input_ids'''				)

               __snake_case								=       model(a__    ,      **a__				)[0]
               self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]				)

               # Test that model correctly compute the loss when we mask some positions
               __snake_case								=       self._prepare_for_class(inputs_dict.copy()    ,      a__    ,      return_labels=a__				)
               __snake_case								=       prepared_for_class.pop('''input_ids'''				)
               if "labels" in prepared_for_class:
                  __snake_case								=       prepared_for_class['''labels'''].numpy()
                  if len(labels.shape				) > 1 and labels.shape[1] != 1:
                     __snake_case								=       -100
                     __snake_case								=       tf.convert_to_tensor(a__				)
                     __snake_case								=       model(a__    ,      **a__				)[0]
                     self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]				)
                     self.assertTrue(not np.any(np.isnan(loss.numpy()				)				)				)

                # Test that model correctly compute the loss with a dict
               __snake_case								=       self._prepare_for_class(inputs_dict.copy()    ,      a__    ,      return_labels=a__				)
               __snake_case								=       model(a__				)[0]
               self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]				)

               # Test that model correctly compute the loss with a tuple
               __snake_case								=       self._prepare_for_class(inputs_dict.copy()    ,      a__    ,      return_labels=a__				)

               # Get keys that were added with the _prepare_for_class function
               __snake_case								=       prepared_for_class.keys() - inputs_dict.keys()
               __snake_case								=       inspect.signature(model.call				).parameters
               __snake_case								=       list(signature.keys()				)

               # Create a dictionary holding the location of the tensors in the tuple
               __snake_case								=       {0: '''input_ids'''}
               for label_key in label_keys:
                  __snake_case								=       signature_names.index(a__				)
                  __snake_case								=       label_key
               __snake_case								=       sorted(tuple_index_mapping.items()				)
               # Initialize a list with their default values, update the values and convert to a tuple
               __snake_case								=       []

               for name in signature_names:
                  if name != "kwargs":
                     list_input.append(signature[name].default				)

               for index, value in sorted_tuple_index_mapping:
                  __snake_case								=       prepared_for_class[value]

               __snake_case								=       tuple(a__				)

               # Send to model
               __snake_case								=       model(tuple_input[:-1]				)[0]

               self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1]				)


      def        a			(self	:				List[Any]				):





         """simple docstring"""



         (
             (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,          
         )								=       self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__				)


      def        a			(self	:				Tuple				):





         """simple docstring"""



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


      def        a			(self	:				Any				):





         """simple docstring"""



         (
             (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,          
         )								=       self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(
             a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__				)


      def        a			(self	:				Tuple				):





         """simple docstring"""



         (
             (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,          
         )								=       self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(
             a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__				)


      def        a			(self	:				Optional[int]				):





         """simple docstring"""



         (
             (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,     (
             __snake_case     
         )	,          
         )								=       self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(
             a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__    ,      a__				)


      @slow
      def        a			(self	:				int				):





         """simple docstring"""



         for model_name in TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            __snake_case								=       TFLayoutLMvaModel.from_pretrained(a__				)
            self.assertIsNotNone(a__				)






def lowerCamelCase__   (							)				->    str:
   __snake_case								=       Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''	)
   return image







@require_tf
class 		SCREAMING_SNAKE_CASE__    (	unittest.TestCase  ):


      @cached_property
      def        a			(self	:				Optional[Any]				):





         """simple docstring"""



         return LayoutLMvaImageProcessor(apply_ocr=a__				) if is_vision_available() else None


      @slow
      def        a			(self	:				List[str]				):





         """simple docstring"""



         __snake_case								=       TFLayoutLMvaModel.from_pretrained('''microsoft/layoutlmv3-base'''				)

         __snake_case								=       self.default_image_processor
         __snake_case								=       prepare_img()
         __snake_case								=       image_processor(images=a__    ,      return_tensors='''tf'''				).pixel_values

         __snake_case								=       tf.constant([[1, 2]]				)
         __snake_case								=       tf.expand_dims(tf.constant([[1, 2, 3, 4], [5, 6, 7, 8]]				)    ,      axis=0				)

         # forward pass
         __snake_case								=       model(input_ids=a__    ,      bbox=a__    ,      pixel_values=a__    ,      training=a__				)

         # verify the logits
         __snake_case								=       (1, 199, 768)
         self.assertEqual(outputs.last_hidden_state.shape    ,      a__				)

         __snake_case								=       tf.constant(
             [[-0.0_5_2_9, 0.3_6_1_8, 0.1_6_3_2], [-0.1_5_8_7, -0.1_6_6_7, -0.0_4_0_0], [-0.1_5_5_7, -0.1_6_7_1, -0.0_5_0_5]]				)

         self.assertTrue(np.allclose(outputs.last_hidden_state[0, :3, :3]    ,      a__    ,      atol=1E-4				)				)








import functools
import operator

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


snake_case_           =      logging.get_logger(__name__)

snake_case_           =      {
    'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json',
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}

class 		SCREAMING_SNAKE_CASE__    (	_UpperCAmelCase  ):
      A_						:    str							=   'sew-d'


      def __init__(self	:				str    ,      a__	:				List[Any]=32    ,      a__	:				Optional[int]=768    ,      a__	:				Union[str, Any]=12    ,      a__	:				Tuple=12    ,      a__	:				int=3072    ,      a__	:				List[Any]=2    ,      a__	:				Dict=512    ,      a__	:				Dict=256    ,      a__	:				List[str]=True    ,      a__	:				List[str]=True    ,      a__	:				str=("p2c", "c2p")    ,      a__	:				str="layer_norm"    ,      a__	:				str="gelu_python"    ,      a__	:				List[Any]=0.1    ,      a__	:				Dict=0.1    ,      a__	:				Optional[Any]=0.1    ,      a__	:				Union[str, Any]=0.0    ,      a__	:				Dict=0.1    ,      a__	:				int=0.0_2    ,      a__	:				str=1E-7    ,      a__	:				Union[str, Any]=1E-5    ,      a__	:				Union[str, Any]="group"    ,      a__	:				Optional[Any]="gelu"    ,      a__	:				List[Any]=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)    ,      a__	:				Union[str, Any]=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)    ,      a__	:				Optional[int]=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)    ,      a__	:				List[str]=False    ,      a__	:				Optional[Any]=128    ,      a__	:				Union[str, Any]=16    ,      a__	:				Optional[Any]=True    ,      a__	:				List[Any]=0.0_5    ,      a__	:				Tuple=10    ,      a__	:				str=2    ,      a__	:				int=0.0    ,      a__	:				Optional[Any]=10    ,      a__	:				List[Any]=0    ,      a__	:				Optional[int]="mean"    ,      a__	:				List[str]=False    ,      a__	:				Tuple=False    ,      a__	:				Optional[int]=256    ,      a__	:				str=0    ,      a__	:				List[Any]=1    ,      a__	:				int=2    ,      **a__	:				List[str]    ,      ):





         """simple docstring"""



         super().__init__(**a__    ,      pad_token_id=a__    ,      bos_token_id=a__    ,      eos_token_id=a__				)
         __snake_case								=       hidden_size
         __snake_case								=       feat_extract_norm
         __snake_case								=       feat_extract_activation
         __snake_case								=       list(a__				)
         __snake_case								=       list(a__				)
         __snake_case								=       list(a__				)
         __snake_case								=       conv_bias
         __snake_case								=       num_conv_pos_embeddings
         __snake_case								=       num_conv_pos_embedding_groups
         __snake_case								=       len(self.conv_dim				)
         __snake_case								=       num_hidden_layers
         __snake_case								=       intermediate_size
         __snake_case								=       squeeze_factor
         __snake_case								=       max_position_embeddings
         __snake_case								=       position_buckets
         __snake_case								=       share_att_key
         __snake_case								=       relative_attention
         __snake_case								=       norm_rel_ebd
         __snake_case								=       list(a__				)
         __snake_case								=       hidden_act
         __snake_case								=       num_attention_heads
         __snake_case								=       hidden_dropout
         __snake_case								=       attention_dropout
         __snake_case								=       activation_dropout
         __snake_case								=       feat_proj_dropout
         __snake_case								=       final_dropout
         __snake_case								=       layer_norm_eps
         __snake_case								=       feature_layer_norm_eps
         __snake_case								=       initializer_range
         __snake_case								=       vocab_size

         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)`,'''
                f"""but is `len(config.conv_dim) = {len(self.conv_dim				)}`, `len(config.conv_stride)"""
                f"""= {len(self.conv_stride				)}`, `len(config.conv_kernel) = {len(self.conv_kernel				)}`."""				)

         # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
         __snake_case								=       apply_spec_augment
         __snake_case								=       mask_time_prob
         __snake_case								=       mask_time_length
         __snake_case								=       mask_time_min_masks
         __snake_case								=       mask_feature_prob
         __snake_case								=       mask_feature_length
         __snake_case								=       mask_feature_min_masks

         # ctc loss
         __snake_case								=       ctc_loss_reduction
         __snake_case								=       ctc_zero_infinity

         # sequence classification
         __snake_case								=       use_weighted_layer_sum
         __snake_case								=       classifier_proj_size


      @property
      def        a			(self	:				List[Any]				):





         """simple docstring"""



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

