import unittest

from transformers import FunnelConfig, FunnelTokenizer, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import (
      MODEL_FOR_PRETRAINING_MAPPING,
      FunnelBaseModel,
      FunnelForMaskedLM,
      FunnelForMultipleChoice,
      FunnelForPreTraining,
      FunnelForQuestionAnswering,
      FunnelForSequenceClassification,
      FunnelForTokenClassification,
      FunnelModel,
  )



class 				__snake_case  :


    '''simple docstring'''







    def __init__(					self      ,							A_      ,							A_=13      ,							A_=7      ,							A_=True      ,							A_=True      ,							A_=True      ,							A_=True      ,							A_=99      ,							A_=[1, 1, 2]      ,							A_=1      ,							A_=32      ,							A_=4      ,							A_=8      ,							A_=37      ,							A_="gelu_new"      ,							A_=0.1      ,							A_=0.1      ,							A_=0.0      ,							A_=5_12      ,							A_=3      ,							A_=0.02      ,							A_=3      ,							A_=4      ,							A_=None      ,							A_=False      ,							):





        '''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__       							= block_sizes
        SCREAMING_SNAKE_CASE__       							= num_decoder_layers
        SCREAMING_SNAKE_CASE__       							= d_model
        SCREAMING_SNAKE_CASE__       							= n_head
        SCREAMING_SNAKE_CASE__       							= d_head
        SCREAMING_SNAKE_CASE__       							= d_inner
        SCREAMING_SNAKE_CASE__       							= hidden_act
        SCREAMING_SNAKE_CASE__       							= hidden_dropout
        SCREAMING_SNAKE_CASE__       							= attention_dropout
        SCREAMING_SNAKE_CASE__       							= activation_dropout
        SCREAMING_SNAKE_CASE__       							= max_position_embeddings
        SCREAMING_SNAKE_CASE__       							= type_vocab_size
        SCREAMING_SNAKE_CASE__       							= 2
        SCREAMING_SNAKE_CASE__       							= num_labels
        SCREAMING_SNAKE_CASE__       							= num_choices
        SCREAMING_SNAKE_CASE__       							= scope
        SCREAMING_SNAKE_CASE__       							= initializer_std

        # Used in the tests to check the size of the first attention layer
        SCREAMING_SNAKE_CASE__       							= n_head
        # Used in the tests to check the size of the first hidden state
        SCREAMING_SNAKE_CASE__       							= self.d_model
        # Used in the tests to check the number of output hidden states/attentions
        SCREAMING_SNAKE_CASE__       							= sum(self.block_sizes    ) + (0 if base else self.num_decoder_layers)
        # FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
        # the last hidden state of the first block (which is the first hidden state of the decoder).
        if not base:
            SCREAMING_SNAKE_CASE__       							= self.num_hidden_layers + 2



    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__       							= ids_tensor([self.batch_size, self.seq_length]      ,							vocab_size=2    )

        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__       							= ids_tensor([self.batch_size, self.seq_length]      ,							1    )

        SCREAMING_SNAKE_CASE__       							= self.get_config()

        return (
            config,
            input_ids,
            token_type_ids,
            input_mask,
            sequence_labels,
            token_labels,
            choice_labels,
            fake_token_labels,
        )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        return FunnelConfig(
            vocab_size=self.vocab_size      ,							block_sizes=self.block_sizes      ,							num_decoder_layers=self.num_decoder_layers      ,							d_model=self.d_model      ,							n_head=self.n_head      ,							d_head=self.d_head      ,							d_inner=self.d_inner      ,							hidden_act=self.hidden_act      ,							hidden_dropout=self.hidden_dropout      ,							attention_dropout=self.attention_dropout      ,							activation_dropout=self.activation_dropout      ,							max_position_embeddings=self.max_position_embeddings      ,							type_vocab_size=self.type_vocab_size      ,							initializer_std=self.initializer_std      ,							)



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= FunnelModel(config=A_    )
        model.to(A_    )
        model.eval()
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							attention_mask=A_      ,							token_type_ids=A_    )
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							token_type_ids=A_    )
        SCREAMING_SNAKE_CASE__       							= model(A_    )
        self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, self.seq_length, self.d_model)    )

        SCREAMING_SNAKE_CASE__       							= False
        SCREAMING_SNAKE_CASE__       							= model(A_    )
        self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, self.seq_length, self.d_model)    )

        SCREAMING_SNAKE_CASE__       							= False
        SCREAMING_SNAKE_CASE__       							= model(A_    )
        self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, self.seq_length, self.d_model)    )



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= FunnelBaseModel(config=A_    )
        model.to(A_    )
        model.eval()
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							attention_mask=A_      ,							token_type_ids=A_    )
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							token_type_ids=A_    )
        SCREAMING_SNAKE_CASE__       							= model(A_    )
        self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, 2, self.d_model)    )

        SCREAMING_SNAKE_CASE__       							= False
        SCREAMING_SNAKE_CASE__       							= model(A_    )
        self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, 3, self.d_model)    )

        SCREAMING_SNAKE_CASE__       							= False
        SCREAMING_SNAKE_CASE__       							= model(A_    )
        self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, 2, self.d_model)    )



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

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



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

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



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.num_labels
        SCREAMING_SNAKE_CASE__       							= FunnelForSequenceClassification(A_    )
        model.to(A_    )
        model.eval()
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							attention_mask=A_      ,							token_type_ids=A_      ,							labels=A_    )
        self.parent.assertEqual(result.logits.shape      ,							(self.batch_size, self.num_labels)    )



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.num_choices
        SCREAMING_SNAKE_CASE__       							= FunnelForMultipleChoice(config=A_    )
        model.to(A_    )
        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(
            A_      ,							attention_mask=A_      ,							token_type_ids=A_      ,							labels=A_      ,							)
        self.parent.assertEqual(result.logits.shape      ,							(self.batch_size, self.num_choices)    )



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

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



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= FunnelForQuestionAnswering(config=A_    )
        model.to(A_    )
        model.eval()
        SCREAMING_SNAKE_CASE__       							= model(
            A_      ,							attention_mask=A_      ,							token_type_ids=A_      ,							start_positions=A_      ,							end_positions=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    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__		
        )							,		(
            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  (     __SCREAMING_SNAKE_CASE ,    __SCREAMING_SNAKE_CASE ,    unittest.TestCase						):


    '''simple docstring'''







    lowerCamelCase__						:		str							=  False
    lowerCamelCase__						:		int							=  False
    lowerCamelCase__						:		Dict							=  (
        (
            FunnelModel,
            FunnelForMaskedLM,
            FunnelForPreTraining,
            FunnelForQuestionAnswering,
            FunnelForTokenClassification,
        )
        if is_torch_available()
        else ()
    )
    lowerCamelCase__						:		int							=  (
        {
            """feature-extraction""": (FunnelBaseModel, FunnelModel),
            """fill-mask""": FunnelForMaskedLM,
            """question-answering""": FunnelForQuestionAnswering,
            """text-classification""": FunnelForSequenceClassification,
            """token-classification""": FunnelForTokenClassification,
            """zero-shot""": FunnelForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )



    def    lowercase_				(					self      ,							A_      ,							A_      ,							A_=False    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= super()._prepare_for_class(A_      ,							A_      ,							return_labels=A_    )

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



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= FunnelModelTester(self    )
        SCREAMING_SNAKE_CASE__       							= ConfigTester(self      ,							config_class=A_    )



    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(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_pretraining(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_masked_lm(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_token_classification(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_question_answering(*A_    )




    def    lowercase_				(					self      ,							A_    ):





        '''simple docstring'''

        if hasattr(A_      ,							'''weight'''    ) and module.weight is not None:
            module.weight.data.fill_(3    )
        if hasattr(A_      ,							'''bias'''    ) and module.bias is not None:
            module.bias.data.fill_(3    )

        for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
            if hasattr(A_      ,							A_    ) and getattr(A_      ,							A_    ) is not None:
                SCREAMING_SNAKE_CASE__       							= getattr(A_      ,							A_    )
                weight.data.fill_(3    )





@require_torch
class 				__snake_case  (     __SCREAMING_SNAKE_CASE ,    unittest.TestCase						):


    '''simple docstring'''







    lowerCamelCase__						:		Optional[int]							=  False
    lowerCamelCase__						:		Any							=  False
    lowerCamelCase__						:		List[str]							=  (
        (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= FunnelModelTester(self      ,							base=A_    )
        SCREAMING_SNAKE_CASE__       							= ConfigTester(self      ,							config_class=A_    )



    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_base_model(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_sequence_classification(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_multiple_choice(*A_    )



    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__							,		SCREAMING_SNAKE_CASE__       							= self.model_tester.prepare_config_and_inputs_for_common()
        SCREAMING_SNAKE_CASE__       							= True

        for model_class in self.all_model_classes:
            if model_class.__name__ == "FunnelBaseModel":
                continue
            SCREAMING_SNAKE_CASE__       							= model_class(A_    )
            model.to(A_    )
            model.train()
            SCREAMING_SNAKE_CASE__       							= self._prepare_for_class(A_      ,							A_      ,							return_labels=A_    )
            SCREAMING_SNAKE_CASE__       							= model(**A_    ).loss
            loss.backward()




    def    lowercase_				(					self      ,							A_    ):





        '''simple docstring'''

        if hasattr(A_      ,							'''weight'''    ) and module.weight is not None:
            module.weight.data.fill_(3    )
        if hasattr(A_      ,							'''bias'''    ) and module.bias is not None:
            module.bias.data.fill_(3    )

        for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
            if hasattr(A_      ,							A_    ) and getattr(A_      ,							A_    ) is not None:
                SCREAMING_SNAKE_CASE__       							= getattr(A_      ,							A_    )
                weight.data.fill_(3    )





@require_torch
@require_sentencepiece
@require_tokenizers
class 				__snake_case  (     unittest.TestCase						):


    '''simple docstring'''







    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= 13
        SCREAMING_SNAKE_CASE__       							= 7
        SCREAMING_SNAKE_CASE__       							= torch.arange(0      ,							batch_size * sequence_length    ).long().reshape(A_      ,							A_    )
        SCREAMING_SNAKE_CASE__       							= [0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
        SCREAMING_SNAKE_CASE__       							= torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]    )

        SCREAMING_SNAKE_CASE__       							= FunnelModel.from_pretrained('''sgugger/funnel-random-tiny'''    )
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							token_type_ids=A_    )[0].abs()

        SCREAMING_SNAKE_CASE__       							= torch.tensor(2344.8352    )
        SCREAMING_SNAKE_CASE__       							= torch.tensor(0.8052    )
        self.assertTrue(torch.allclose(output.sum()      ,							A_      ,							atol=1E-4    )    )
        self.assertTrue(torch.allclose(output.mean()      ,							A_      ,							atol=1E-4    )    )

        SCREAMING_SNAKE_CASE__       							= torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]    )
        SCREAMING_SNAKE_CASE__       							= model(A_      ,							attention_mask=A_      ,							token_type_ids=A_    )[0].abs()

        SCREAMING_SNAKE_CASE__       							= torch.tensor(2343.8425    )
        SCREAMING_SNAKE_CASE__       							= torch.tensor(0.8049    )
        self.assertTrue(torch.allclose(output.sum()      ,							A_      ,							atol=1E-4    )    )
        self.assertTrue(torch.allclose(output.mean()      ,							A_      ,							atol=1E-4    )    )




    @slow
    def    lowercase_				(					self    ):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__       							= FunnelTokenizer.from_pretrained('''huggingface/funnel-small'''    )
        SCREAMING_SNAKE_CASE__       							= FunnelModel.from_pretrained('''huggingface/funnel-small'''    )
        SCREAMING_SNAKE_CASE__       							= tokenizer('''Hello! I am the Funnel Transformer model.'''      ,							return_tensors='''pt'''    )
        SCREAMING_SNAKE_CASE__       							= model(**A_    )[0]

        SCREAMING_SNAKE_CASE__       							= torch.tensor(235.7246    )
        SCREAMING_SNAKE_CASE__       							= torch.tensor(0.0256    )
        self.assertTrue(torch.allclose(output.sum()      ,							A_      ,							atol=1E-4    )    )
        self.assertTrue(torch.allclose(output.mean()      ,							A_      ,							atol=1E-4    )    )







import functools
import operator

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


_A				:							Any							= logging.get_logger(__name__)

_A				:							Any							= {
    """facebook/hubert-base-ls960""": """https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json""",
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}



class 				__snake_case  (     __SCREAMING_SNAKE_CASE						):


    '''simple docstring'''







    lowerCamelCase__						:		int							=  """hubert"""



    def __init__(					self      ,							A_=32      ,							A_=7_68      ,							A_=12      ,							A_=12      ,							A_=30_72      ,							A_="gelu"      ,							A_=0.1      ,							A_=0.1      ,							A_=0.1      ,							A_=True      ,							A_=0.0      ,							A_=0.1      ,							A_=0.1      ,							A_=0.02      ,							A_=1E-5      ,							A_="group"      ,							A_="gelu"      ,							A_=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)      ,							A_=(5, 2, 2, 2, 2, 2, 2)      ,							A_=(10, 3, 3, 3, 3, 2, 2)      ,							A_=False      ,							A_=1_28      ,							A_=16      ,							A_=False      ,							A_=True      ,							A_=0.05      ,							A_=10      ,							A_=2      ,							A_=0.0      ,							A_=10      ,							A_=0      ,							A_="sum"      ,							A_=False      ,							A_=False      ,							A_=2_56      ,							A_=0      ,							A_=1      ,							A_=2      ,							**A_      ,							):





        '''simple docstring'''

        super().__init__(**A_      ,							pad_token_id=A_      ,							bos_token_id=A_      ,							eos_token_id=A_    )
        SCREAMING_SNAKE_CASE__       							= hidden_size
        SCREAMING_SNAKE_CASE__       							= feat_extract_norm
        SCREAMING_SNAKE_CASE__       							= feat_extract_activation
        SCREAMING_SNAKE_CASE__       							= list(A_    )
        SCREAMING_SNAKE_CASE__       							= list(A_    )
        SCREAMING_SNAKE_CASE__       							= list(A_    )
        SCREAMING_SNAKE_CASE__       							= conv_bias
        SCREAMING_SNAKE_CASE__       							= num_conv_pos_embeddings
        SCREAMING_SNAKE_CASE__       							= num_conv_pos_embedding_groups
        SCREAMING_SNAKE_CASE__       							= len(self.conv_dim    )
        SCREAMING_SNAKE_CASE__       							= num_hidden_layers
        SCREAMING_SNAKE_CASE__       							= intermediate_size
        SCREAMING_SNAKE_CASE__       							= hidden_act
        SCREAMING_SNAKE_CASE__       							= num_attention_heads
        SCREAMING_SNAKE_CASE__       							= hidden_dropout
        SCREAMING_SNAKE_CASE__       							= attention_dropout
        SCREAMING_SNAKE_CASE__       							= activation_dropout
        SCREAMING_SNAKE_CASE__       							= feat_proj_layer_norm
        SCREAMING_SNAKE_CASE__       							= feat_proj_dropout
        SCREAMING_SNAKE_CASE__       							= final_dropout
        SCREAMING_SNAKE_CASE__       							= layerdrop
        SCREAMING_SNAKE_CASE__       							= layer_norm_eps
        SCREAMING_SNAKE_CASE__       							= initializer_range
        SCREAMING_SNAKE_CASE__       							= vocab_size
        SCREAMING_SNAKE_CASE__       							= do_stable_layer_norm
        SCREAMING_SNAKE_CASE__       							= use_weighted_layer_sum
        SCREAMING_SNAKE_CASE__       							= classifier_proj_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)`, 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
        SCREAMING_SNAKE_CASE__       							= apply_spec_augment
        SCREAMING_SNAKE_CASE__       							= mask_time_prob
        SCREAMING_SNAKE_CASE__       							= mask_time_length
        SCREAMING_SNAKE_CASE__       							= mask_time_min_masks
        SCREAMING_SNAKE_CASE__       							= mask_feature_prob
        SCREAMING_SNAKE_CASE__       							= mask_feature_length
        SCREAMING_SNAKE_CASE__       							= mask_feature_min_masks

        # ctc loss
        SCREAMING_SNAKE_CASE__       							= ctc_loss_reduction
        SCREAMING_SNAKE_CASE__       							= ctc_zero_infinity




    @property
    def    lowercase_				(					self    ):





        '''simple docstring'''

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