code: def check_encoder_decoder_model_output_attentions(
      self,
      config,
      attention_mask,
      decoder_config,
      decoder_input_ids,
      decoder_attention_mask,
      labels=None,
      input_values=None,
      input_features=None,
      **kwargs,
  ):
      # make the decoder inputs a different shape from the encoder inputs to harden the test
      decoder_input_ids = decoder_input_ids[:, :-1]
      decoder_attention_mask = decoder_attention_mask[:, :-1]
      encoder_model, decoder_model = self.get_encoder_decoder_model(
          config, decoder_config
      )
      enc_dec_model = SpeechEncoderDecoderModel(
          encoder=encoder_model, decoder=decoder_model
      )
      enc_dec_model.to(torch_device)
      outputs_encoder_decoder = enc_dec_model(
          input_values=input_values,
          input_features=input_features,
          decoder_input_ids=decoder_input_ids,
          attention_mask=attention_mask,
          decoder_attention_mask=decoder_attention_mask,
          output_attentions=True,
      )
  
      inputs = (
          input_values if input_features is None else input_features
      )
  
      encoder_attentions = outputs_encoder_decoder["encoder_attentions"]
      self.assertEqual(
          len(encoder_attentions), config.num_hidden_layers
      )
  
      seq_len = enc_dec_model.encoder._get_feat_extract_output_lengths(
          inputs.shape[1]
      )
      self.assertEqual(
          encoder_attentions[0].shape[-3:],
          (config.num_attention_heads, seq_len, seq_len),
      )
  
      decoder_attentions = outputs_encoder_decoder["decoder_attentions"]
      num_decoder_layers = (
          decoder_config.num_decoder_layers
          if hasattr(decoder_config, "num_decoder_layers")
          else decoder_config.num_hidden_layers
      )
      self.assertEqual(len(decoder_attentions), num_decoder_layers)
  
      self.assertEqual(
          decoder_attentions[0].shape[-3:],
          (
              decoder_config.num_attention_heads,
              decoder_input_ids.shape[-1],
              decoder_input_ids.shape[-1],
          ),
      )
  
      cross_attentions = outputs_encoder_decoder["cross_attentions"]
      self.assertEqual(len(cross_attentions), num_decoder_layers)
  
      cross_attention_input_seq_len = decoder_input_ids.shape[-1]
      self.assertEqual(
          cross_attentions[0].shape[-3:],
          (
              decoder_config.num_attention_heads,
              cross_attention_input_seq_len,
              seq_len,
          ),
      )
  
imports: import tempfile
  import unittest
  from transformers import is_torch_available
  from transformers.testing_utils import require_torch, slow, torch_device
  from ...test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
  from ..bert.test_modeling_bert import BertModelTester
  from ..speech_to_text.test_modeling_speech_to_text import Speech2TextModelTester
  from ..speech_to_text_2.test_modeling_speech_to_text_2 import Speech2Text2StandaloneDecoderModelTester
  from ..wav2vec2.test_modeling_wav2vec2 import Wav2Vec2ModelTester
label_desc: Use image node_id 10 for calling the EncoderDecoderMixin obj's underlying member method code with example usage: obj.check_encoder_decoder_model_output_attentions(config, attention_mask, decoder_config, decoder_input_ids, decoder_attention_mask, labels, input_values, input_features) without return types