






import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import MaskaFormerConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

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


if is_torch_available():
       import torch

       from transformers import MaskaFormerForUniversalSegmentation, MaskaFormerModel

       if is_vision_available():
              from transformers import MaskaFormerImageProcessor

if is_vision_available():
       from PIL import Image







class  _lowercase   :
      def __init__(     self				,			a				,			a=2				,			a=True				,			a=False				,			a=1_0				,			a=3				,			a=3_2 * 8				,			a=3_2 * 8				,			a=4				,			a=6_4				,			):
       snake_case__  :    List[Any]							       =parent
       snake_case__  :    Optional[int]							       =batch_size
       snake_case__  :    int							       =is_training
       snake_case__  :    int							       =use_auxiliary_loss
       snake_case__  :    str							       =num_queries
       snake_case__  :    Optional[int]							       =num_channels
       snake_case__  :    Any							       =min_size
       snake_case__  :    List[str]							       =max_size
       snake_case__  :    Dict							       =num_labels
       snake_case__  :    str							       =hidden_dim
       snake_case__  :    Union[str, Any]							       =hidden_dim
      def 						lowercase__					(     self   ):
       snake_case__  :    str							       =floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]   ).to(
           __lowercase   )

       snake_case__  :    Tuple							       =torch.ones([self.batch_size, self.min_size, self.max_size]				,			device=__lowercase   )

       snake_case__  :    Union[str, Any]							       =(
           torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]				,			device=__lowercase   ) > 0.5
       ).float()
       snake_case__  :    Optional[Any]							       =(torch.rand((self.batch_size, self.num_labels)				,			device=__lowercase   ) > 0.5).long()

       snake_case__  :    Optional[int]							       =self.get_config()
       return config, pixel_values, pixel_mask, mask_labels, class_labels
      def 						lowercase__					(     self   ):
       snake_case__  :    int							       =MaskaFormerConfig(
           hidden_size=self.hidden_dim				,			)
       snake_case__  :    Tuple							       =self.num_queries
       snake_case__  :    Optional[int]							       =self.num_labels

       snake_case__  :    Optional[Any]							       =[1, 1, 1, 1]
       snake_case__  :    str							       =self.num_channels

       snake_case__  :    str							       =6_4
       snake_case__  :    List[str]							       =1_2_8
       snake_case__  :    Dict							       =self.hidden_dim
       snake_case__  :    Tuple							       =self.hidden_dim
       snake_case__  :    Optional[int]							       =self.hidden_dim
       return config
      def 						lowercase__					(     self   ):
       snake_case__       ,   snake_case__       ,   snake_case__       ,   snake_case__       ,   snake_case__  :    Dict							       =self.prepare_config_and_inputs()
       snake_case__  :    List[str]							       ={"""pixel_values""": pixel_values, """pixel_mask""": pixel_mask}
       return config, inputs_dict
      def 						lowercase__					(     self				,			a				,			a   ):
       snake_case__  :    Tuple							       =output.encoder_hidden_states
       snake_case__  :    str							       =output.pixel_decoder_hidden_states
       snake_case__  :    Union[str, Any]							       =output.transformer_decoder_hidden_states

       self.parent.assertTrue(len(__lowercase   )				,			len(config.backbone_config.depths   )   )
       self.parent.assertTrue(len(__lowercase   )				,			len(config.backbone_config.depths   )   )
       self.parent.assertTrue(len(__lowercase   )				,			config.decoder_layers   )
      def 						lowercase__					(     self				,			a				,			a				,			a				,			a=False   ):
       with torch.no_grad():
        snake_case__  :    List[Any]							       =MaskaFormerModel(config=__lowercase   )
        model.to(__lowercase   )
        model.eval()

        snake_case__  :    Union[str, Any]							       =model(pixel_values=__lowercase				,			pixel_mask=__lowercase   )
        snake_case__  :    Union[str, Any]							       =model(__lowercase				,			output_hidden_states=__lowercase   )

       self.parent.assertEqual(
           output.transformer_decoder_last_hidden_state.shape				,			(self.batch_size, self.num_queries, self.hidden_dim)				,			)
       # let's ensure the other two hidden state exists
       self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None   )
       self.parent.assertTrue(output.encoder_last_hidden_state is not None   )

       if output_hidden_states:
        self.check_output_hidden_state(__lowercase				,			__lowercase   )



      def 						lowercase__					(     self				,			a				,			a				,			a				,			a				,			a   ):
       snake_case__  :    Dict							       =MaskaFormerForUniversalSegmentation(config=__lowercase   )
       model.to(__lowercase   )
       model.eval()

       def comm_check_on_output(a   ):
        # let's still check that all the required stuff is there
        self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None   )
        self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None   )
        self.parent.assertTrue(result.encoder_last_hidden_state is not None   )
        # okay, now we need to check the logits shape
        # due to the encoder compression, masks have a //4 spatial size
        self.parent.assertEqual(
            result.masks_queries_logits.shape				,			(self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)				,			)
        # + 1 for null class
        self.parent.assertEqual(
            result.class_queries_logits.shape				,			(self.batch_size, self.num_queries, self.num_labels + 1)   )

       with torch.no_grad():
        snake_case__  :    int							       =model(pixel_values=__lowercase				,			pixel_mask=__lowercase   )
        snake_case__  :    Dict							       =model(__lowercase   )

        comm_check_on_output(__lowercase   )

        snake_case__  :    Optional[Any]							       =model(
            pixel_values=__lowercase				,			pixel_mask=__lowercase				,			mask_labels=__lowercase				,			class_labels=__lowercase   )

       comm_check_on_output(__lowercase   )

       self.parent.assertTrue(result.loss is not None   )
       self.parent.assertEqual(result.loss.shape				,			torch.Size([1]   )   )







@require_torch
class  _lowercase   (   lowercase__						,				lowercase__						,				unittest.TestCase						):
      _a							:						Any										=							(MaskaFormerModel, MaskaFormerForUniversalSegmentation) if is_torch_available() else ()
      _a							:						Tuple										=							{"""feature-extraction""": MaskaFormerModel} if is_torch_available() else {}

      _a							:						int										=							False
      _a							:						Optional[int]										=							False
      _a							:						Optional[int]										=							False
      _a							:						List[str]										=							False
      def 						lowercase__					(     self   ):
       snake_case__  :    Tuple							       =MaskaFormerModelTester(self   )
       snake_case__  :    Any							       =ConfigTester(self				,			config_class=__lowercase				,			has_text_modality=__lowercase   )
      def 						lowercase__					(     self   ):
       self.config_tester.run_common_tests()
      def 						lowercase__					(     self   ):
       snake_case__       ,   snake_case__  :    Union[str, Any]							       =self.model_tester.prepare_config_and_inputs_for_common()
       self.model_tester.create_and_check_maskaformer_model(__lowercase				,			**__lowercase				,			output_hidden_states=__lowercase   )
      def 						lowercase__					(     self   ):
       snake_case__  :    Optional[Any]							       =self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_maskaformer_instance_segmentation_head_model(*__lowercase   )
      @unittest.skip(reason="""Mask2Former does not use inputs_embeds"""   )
      def 						lowercase__					(     self   ):
       pass
      @unittest.skip(reason="""Mask2Former does not have a get_input_embeddings method"""   )
      def 						lowercase__					(     self   ):
       pass
      @unittest.skip(reason="""Mask2Former is not a generative model"""   )
      def 						lowercase__					(     self   ):
       pass
      @unittest.skip(reason="""Mask2Former does not use token embeddings"""   )
      def 						lowercase__					(     self   ):
       pass
      @require_torch_multi_gpu
      @unittest.skip(
          reason="""Mask2Former has some layers using `add_module` which doesn't work well with `nn.DataParallel`"""   )
      def 						lowercase__					(     self   ):
       pass
      @unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""   )
      def 						lowercase__					(     self   ):
       pass
      def 						lowercase__					(     self   ):
       snake_case__       ,   snake_case__  :    Tuple							       =self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
        snake_case__  :    str							       =model_class(__lowercase   )
        snake_case__  :    Dict							       =inspect.signature(model.forward   )
        # signature.parameters is an OrderedDict => so arg_names order is deterministic
        snake_case__  :    Union[str, Any]							       =[*signature.parameters.keys()]

        snake_case__  :    Union[str, Any]							       =["""pixel_values"""]
        self.assertListEqual(arg_names[:1]				,			__lowercase   )
      @slow
      def 						lowercase__					(     self   ):
       for model_name in ["facebook/mask2former-swin-small-coco-instance"]:
        snake_case__  :    Optional[Any]							       =MaskaFormerModel.from_pretrained(__lowercase   )
        self.assertIsNotNone(__lowercase   )
      def 						lowercase__					(     self   ):
       snake_case__  :    Optional[Any]							       =(self.model_tester.min_size,) * 2
       snake_case__  :    Optional[Any]							       ={
           """pixel_values""": torch.randn((2, 3, *size)				,			device=__lowercase   ),
           """mask_labels""": torch.randn((2, 1_0, *size)				,			device=__lowercase   ),
           """class_labels""": torch.zeros(2				,			1_0				,			device=__lowercase   ).long(),
       }
       snake_case__  :    Union[str, Any]							       =self.model_tester.get_config()

       snake_case__  :    Optional[int]							       =MaskaFormerForUniversalSegmentation(__lowercase   ).to(__lowercase   )
       snake_case__  :    List[Any]							       =model(**__lowercase   )
       self.assertTrue(outputs.loss is not None   )
      def 						lowercase__					(     self   ):
       snake_case__       ,   snake_case__  :    Optional[Any]							       =self.model_tester.prepare_config_and_inputs_for_common()
       self.model_tester.create_and_check_maskaformer_model(__lowercase				,			**__lowercase				,			output_hidden_states=__lowercase   )
      def 						lowercase__					(     self   ):
       snake_case__       ,   snake_case__  :    int							       =self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
        snake_case__  :    Dict							       =model_class(__lowercase   ).to(__lowercase   )
        snake_case__  :    Optional[Any]							       =model(**__lowercase				,			output_attentions=__lowercase   )
        self.assertTrue(outputs.attentions is not None   )
      def 						lowercase__					(     self   ):
       if not self.model_tester.is_training:
        return

       snake_case__  :    List[str]							       =self.all_model_classes[1]
       snake_case__       ,   snake_case__       ,   snake_case__       ,   snake_case__       ,   snake_case__  :    Tuple							       =self.model_tester.prepare_config_and_inputs()

       snake_case__  :    Tuple							       =model_class(__lowercase   )
       model.to(__lowercase   )
       model.train()

       snake_case__  :    Tuple							       =model(__lowercase				,			mask_labels=__lowercase				,			class_labels=__lowercase   ).loss
       loss.backward()



      def 						lowercase__					(     self   ):
       snake_case__  :    Tuple							       =self.all_model_classes[1]
       snake_case__       ,   snake_case__       ,   snake_case__       ,   snake_case__       ,   snake_case__  :    Dict							       =self.model_tester.prepare_config_and_inputs()
       snake_case__  :    int							       =True
       snake_case__  :    int							       =True

       snake_case__  :    Optional[Any]							       =model_class(__lowercase   ).to(__lowercase   )
       model.train()

       snake_case__  :    Any							       =model(__lowercase				,			mask_labels=__lowercase				,			class_labels=__lowercase   )

       snake_case__  :    Tuple							       =outputs.encoder_hidden_states[0]
       encoder_hidden_states.retain_grad()

       snake_case__  :    Any							       =outputs.pixel_decoder_hidden_states[0]
       pixel_decoder_hidden_states.retain_grad()

       snake_case__  :    Optional[Any]							       =outputs.transformer_decoder_hidden_states[0]
       transformer_decoder_hidden_states.retain_grad()

       snake_case__  :    Union[str, Any]							       =outputs.attentions[0]
       attentions.retain_grad()

       outputs.loss.backward(retain_graph=__lowercase   )

       self.assertIsNotNone(encoder_hidden_states.grad   )
       self.assertIsNotNone(pixel_decoder_hidden_states.grad   )
       self.assertIsNotNone(transformer_decoder_hidden_states.grad   )
       self.assertIsNotNone(attentions.grad   )




__lowerCamelCase	:		str										=   1e-4







def 			A__							(      ):





 '''simple docstring'''







 snake_case__  :    Any							       =Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""	)
 return image







@require_vision
@slow
class  _lowercase   (   unittest.TestCase						):
      @cached_property
      def 						lowercase__					(     self   ):
       return "facebook/mask2former-swin-small-coco-instance"
      @cached_property
      def 						lowercase__					(     self   ):
       return MaskaFormerImageProcessor.from_pretrained(self.model_checkpoints   ) if is_vision_available() else None
      def 						lowercase__					(     self   ):
       snake_case__  :    Any							       =MaskaFormerModel.from_pretrained(self.model_checkpoints   ).to(__lowercase   )
       snake_case__  :    List[Any]							       =self.default_image_processor
       snake_case__  :    int							       =prepare_img()
       snake_case__  :    Tuple							       =image_processor(__lowercase				,			return_tensors="""pt"""   ).to(__lowercase   )
       snake_case__  :    str							       =inputs["""pixel_values"""].shape
       # check size is divisible by 32
       self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0   )
       # check size
       self.assertEqual(__lowercase				,			(1, 3, 3_8_4, 3_8_4)   )

       with torch.no_grad():
        snake_case__  :    Any							       =model(**__lowercase   )

       snake_case__  :    List[Any]							       =torch.tensor(
           [[-0.2790, -1.0717, -1.1668], [-0.5128, -0.3128, -0.4987], [-0.5832, 0.1971, -0.0197]]   ).to(__lowercase   )
       self.assertTrue(
           torch.allclose(
               outputs.encoder_last_hidden_state[0, 0, :3, :3]				,			__lowercase				,			atol=__lowercase   )   )

       snake_case__  :    Tuple							       =torch.tensor(
           [[0.8973, 1.1847, 1.1776], [1.1934, 1.5040, 1.5128], [1.1153, 1.4486, 1.4951]]   ).to(__lowercase   )
       self.assertTrue(
           torch.allclose(
               outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]				,			__lowercase				,			atol=__lowercase   )   )

       snake_case__  :    Tuple							       =torch.tensor(
           [[2.1152, 1.7000, -0.8603], [1.5808, 1.8004, -0.9353], [1.6043, 1.7495, -0.5999]]   ).to(__lowercase   )
       self.assertTrue(
           torch.allclose(
               outputs.transformer_decoder_last_hidden_state[0, :3, :3]				,			__lowercase				,			atol=__lowercase   )   )
      def 						lowercase__					(     self   ):
       snake_case__  :    Optional[Any]							       =MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints   ).to(__lowercase   ).eval()
       snake_case__  :    Optional[Any]							       =self.default_image_processor
       snake_case__  :    Dict							       =prepare_img()
       snake_case__  :    int							       =image_processor(__lowercase				,			return_tensors="""pt"""   ).to(__lowercase   )
       snake_case__  :    Any							       =inputs["""pixel_values"""].shape
       # check size is divisible by 32
       self.assertTrue((inputs_shape[-1] % 3_2) == 0 and (inputs_shape[-2] % 3_2) == 0   )
       # check size
       self.assertEqual(__lowercase				,			(1, 3, 3_8_4, 3_8_4)   )

       with torch.no_grad():
        snake_case__  :    Union[str, Any]							       =model(**__lowercase   )
       # masks_queries_logits
       snake_case__  :    Any							       =outputs.masks_queries_logits
       self.assertEqual(
           masks_queries_logits.shape				,			(1, model.config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)   )
       snake_case__  :    List[str]							       =[
           [-8.7839, -9.0056, -8.8121],
           [-7.4104, -7.0313, -6.5401],
           [-6.6105, -6.3427, -6.4675],
       ]
       snake_case__  :    Any							       =torch.tensor(__lowercase   ).to(__lowercase   )
       self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]				,			__lowercase				,			atol=__lowercase   )   )
       # class_queries_logits
       snake_case__  :    Optional[int]							       =outputs.class_queries_logits
       self.assertEqual(class_queries_logits.shape				,			(1, model.config.num_queries, model.config.num_labels + 1)   )
       snake_case__  :    List[Any]							       =torch.tensor(
           [
               [1.8324, -8.0835, -4.1922],
               [0.8450, -9.0050, -3.6053],
               [0.3045, -7.7293, -3.0275],
           ]   ).to(__lowercase   )
       self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]				,			__lowercase				,			atol=__lowercase   )   )



      def 						lowercase__					(     self   ):
       snake_case__  :    Dict							       =MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints   ).to(__lowercase   ).eval()
       snake_case__  :    Optional[int]							       =self.default_image_processor

       snake_case__  :    Any							       =image_processor(
           [np.zeros((3, 8_0_0, 1_3_3_3)   ), np.zeros((3, 8_0_0, 1_3_3_3)   )]				,			segmentation_maps=[np.zeros((3_8_4, 3_8_4)   ).astype(np.floataa   ), np.zeros((3_8_4, 3_8_4)   ).astype(np.floataa   )]				,			return_tensors="""pt"""				,			)

       snake_case__  :    str							       =inputs["""pixel_values"""].to(__lowercase   )
       snake_case__  :    Tuple							       =[el.to(__lowercase   ) for el in inputs["""mask_labels"""]]
       snake_case__  :    Any							       =[el.to(__lowercase   ) for el in inputs["""class_labels"""]]

       with torch.no_grad():
        snake_case__  :    str							       =model(**__lowercase   )

       self.assertTrue(outputs.loss is not None   )













from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast
from ...utils import logging


if TYPE_CHECKING:
       from ...feature_extraction_utils import FeatureExtractionMixin
       from ...tokenization_utils_base import PreTrainedTokenizerBase
       from ...utils import TensorType

__lowerCamelCase	:		Optional[int]										=   logging.get_logger(__name__)

__lowerCamelCase	:		Optional[int]										=   {
    """openai/whisper-base""": """https://huggingface.co/openai/whisper-base/resolve/main/config.json""",
}

# fmt: off
__lowerCamelCase	:		int										=   [
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_57, 3_66, 4_38, 5_32, 6_85,
    7_05, 7_96, 9_30, 10_58, 12_20, 12_67, 12_79, 13_03, 13_43, 13_77,
    13_91, 16_35, 17_82, 18_75, 21_62, 23_61, 24_88, 34_67, 40_08, 42_11,
    46_00, 48_08, 52_99, 58_55, 63_29, 72_03, 96_09, 99_59, 1_05_63, 1_07_86,
    1_14_20, 1_17_09, 1_19_07, 1_31_63, 1_36_97, 1_37_00, 1_48_08, 1_53_06, 1_64_10, 1_67_91,
    1_79_92, 1_92_03, 1_95_10, 2_07_24, 2_23_05, 2_29_35, 2_70_07, 3_01_09, 3_04_20, 3_34_09,
    3_49_49, 4_02_83, 4_04_93, 4_05_49, 4_72_82, 4_91_46, 5_02_57, 5_03_59, 5_03_60, 5_03_61
]
__lowerCamelCase	:		Dict										=   [
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_59, 5_03, 5_22, 5_42, 8_73,
    8_93, 9_02, 9_18, 9_22, 9_31, 13_50, 18_53, 19_82, 24_60, 26_27,
    32_46, 32_53, 32_68, 35_36, 38_46, 39_61, 41_83, 46_67, 65_85, 66_47,
    72_73, 90_61, 93_83, 1_04_28, 1_09_29, 1_19_38, 1_20_33, 1_23_31, 1_25_62, 1_37_93,
    1_41_57, 1_46_35, 1_52_65, 1_56_18, 1_65_53, 1_66_04, 1_83_62, 1_89_56, 2_00_75, 2_16_75,
    2_25_20, 2_61_30, 2_61_61, 2_64_35, 2_82_79, 2_94_64, 3_16_50, 3_23_02, 3_24_70, 3_68_65,
    4_28_63, 4_74_25, 4_98_70, 5_02_54, 5_02_58, 5_03_60, 5_03_61, 5_03_62
]







class  _lowercase   (   _A						):
      _a							:						List[Any]										=							'whisper'
      _a							:						Any										=							['past_key_values']
      _a							:						Dict										=							{'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}
      def __init__(     self				,			a=5_1_8_6_5				,			a=8_0				,			a=6				,			a=4				,			a=6				,			a=4				,			a=1_5_3_6				,			a=1_5_3_6				,			a=0.0				,			a=0.0				,			a=5_0_2_5_7				,			a=True				,			a=True				,			a="gelu"				,			a=2_5_6				,			a=0.0				,			a=0.0				,			a=0.0				,			a=0.02				,			a=False				,			a=1_5_0_0				,			a=4_4_8				,			a=5_0_2_5_6				,			a=5_0_2_5_6				,			a=5_0_2_5_6				,			a=None				,			a=[2_2_0, 5_0_2_5_6]				,			a=False				,			a=2_5_6				,			a=False				,			a=0.05				,			a=1_0				,			a=2				,			a=0.0				,			a=1_0				,			a=0				,			a=7				,			**a				,			):
       snake_case__  :    Union[str, Any]							       =vocab_size
       snake_case__  :    int							       =num_mel_bins
       snake_case__  :    Tuple							       =d_model
       snake_case__  :    Optional[Any]							       =encoder_layers
       snake_case__  :    List[Any]							       =encoder_attention_heads
       snake_case__  :    Dict							       =decoder_layers
       snake_case__  :    Optional[Any]							       =decoder_attention_heads
       snake_case__  :    str							       =decoder_ffn_dim
       snake_case__  :    str							       =encoder_ffn_dim
       snake_case__  :    List[Any]							       =dropout
       snake_case__  :    Optional[Any]							       =attention_dropout
       snake_case__  :    Tuple							       =activation_dropout
       snake_case__  :    int							       =activation_function
       snake_case__  :    List[str]							       =init_std
       snake_case__  :    List[str]							       =encoder_layerdrop
       snake_case__  :    int							       =decoder_layerdrop
       snake_case__  :    Union[str, Any]							       =use_cache
       snake_case__  :    Tuple							       =encoder_layers
       snake_case__  :    int							       =scale_embedding  # scale factor will be sqrt(d_model) if True
       snake_case__  :    Tuple							       =max_source_positions
       snake_case__  :    Union[str, Any]							       =max_target_positions

       # Audio Classification-specific parameters. Feel free to ignore for other classes.
       snake_case__  :    str							       =classifier_proj_size
       snake_case__  :    List[str]							       =use_weighted_layer_sum

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

       snake_case__  :    Optional[Any]							       =median_filter_width

       super().__init__(
           pad_token_id=a				,			bos_token_id=a				,			eos_token_id=a				,			is_encoder_decoder=a				,			decoder_start_token_id=a				,			suppress_tokens=a				,			begin_suppress_tokens=a				,			**a				,			)







class  _lowercase   (   _A						):
      @property
      def 						lowercase__					(     self   ):
       snake_case__  :    Union[str, Any]							       =OrderedDict(
           [
               ("""input_features""", {0: """batch""", 1: """feature_size""", 2: """encoder_sequence"""}),
           ]   )
       if self.use_past:
        snake_case__  :    List[Any]							       ={0: """batch"""}
       else:
        snake_case__  :    int							       ={0: """batch""", 1: """decoder_sequence"""}

       if self.use_past:
        self.fill_with_past_key_values_(a				,			direction="""inputs"""   )

       return common_inputs
      def 						lowercase__					(     self				,			a				,			a = -1				,			a = -1				,			a = False				,			a = None				,			a = 2_2_0_5_0				,			a = 5.0				,			a = 2_2_0				,			):
       snake_case__  :    Union[str, Any]							       =OrderedDict()
       snake_case__  :    Optional[int]							       =OnnxConfig.generate_dummy_inputs(
           self				,			preprocessor=preprocessor.feature_extractor				,			batch_size=a				,			framework=a				,			sampling_rate=a				,			time_duration=a				,			frequency=a				,			)
       snake_case__  :    Any							       =encoder_inputs["""input_features"""].shape[2]
       snake_case__  :    Dict							       =encoder_sequence_length // 2 if self.use_past else seq_length

       snake_case__  :    List[Any]							       =super().generate_dummy_inputs(
           preprocessor.tokenizer				,			a				,			a				,			a				,			a   )

       snake_case__  :    int							       =encoder_inputs.pop("""input_features"""   )
       snake_case__  :    List[Any]							       =decoder_inputs.pop("""decoder_input_ids"""   )

       if "past_key_values" in decoder_inputs:
        snake_case__  :    int							       =decoder_inputs.pop("""past_key_values"""   )

       return dummy_inputs



      @property
      def 						lowercase__					(     self   ):
       return 1e-3





