class_docstr: Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`Speech2Text2DecoderLayer`]
  
  Args:
      config: Speech2Text2Config
      embed_tokens (nn.Embedding): output embedding
class_docstr_tok: ["Transformer","decoder","consisting","of","*","config.decoder_layers","*","layers",".","Each","layer","is","a","[","`","Speech2Text2DecoderLayer","`","]","Args",":","config",":","Speech2Text2Config","embed_tokens","(","nn.Embedding",")",":","output","embedding"]
code: def _prepare_decoder_attention_mask(
      self,
      attention_mask,
      input_shape,
      inputs_embeds,
      past_key_values_length,
  ):
      # create causal mask
      # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
      combined_attention_mask = None
      if input_shape[-1] > 1:
          combined_attention_mask = _make_causal_mask(
              input_shape,
              inputs_embeds.dtype,
              past_key_values_length=past_key_values_length,
          ).to(inputs_embeds.device)
  
      if attention_mask is not None:
          # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
          expanded_attn_mask = _expand_mask(
              attention_mask,
              inputs_embeds.dtype,
              tgt_len=input_shape[-1],
          )
          combined_attention_mask = (
              expanded_attn_mask
              if combined_attention_mask is None
              else expanded_attn_mask + combined_attention_mask
          )
  
      return combined_attention_mask
  
imports: import copy
  import math
  import random
  from typing import Optional, Tuple
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, logging, replace_return_docstrings
  from .configuration_speech_to_text_2 import Speech2Text2Config
label_desc: Use image node_id 4 for calling the Speech2Text2Decoder obj's underlying member method code with example usage: obj._prepare_decoder_attention_mask(attention_mask, input_shape, inputs_embeds, past_key_values_length) and returns: combined_attention_mask