class_docstr: Multi-headed attention.
  
  See "Attention Is All You Need" for more details.
class_docstr_tok: ["Multi-headed","attention",".","See","``","Attention","Is","All","You","Need","''","for","more","details","."]
code: def _append_zero_attn(
      self,
      k: Tensor,
      v: Tensor,
      key_padding_mask: Optional[Tensor],
      attn_mask: Optional[Tensor],
  ) -> Tuple[Tensor, Tensor, Optional[Tensor], Optional[Tensor]]:
      zero_attn_shape = k.size()[:-2] + torch.Size([1]) + k.size()[-1:]
      k = torch.cat(
          [
              k,
              torch.zeros(
                  zero_attn_shape, dtype=k.dtype, device=k.device
              ),
          ],
          dim=-2,
      )
      v = torch.cat(
          [
              v,
              torch.zeros(
                  zero_attn_shape, dtype=v.dtype, device=v.device
              ),
          ],
          dim=-2,
      )
      key_padding_mask, attn_mask = self._pad_masks(
          key_padding_mask=key_padding_mask, attn_mask=attn_mask
      )
      return k, v, key_padding_mask, attn_mask
  
imports: import math
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from torch.nn import Parameter
  from fairseq import utils
  from fairseq.modules.fairseq_dropout import FairseqDropout
  from fairseq.modules.quant_noise import quant_noise
  from fairseq.models.fairseq_incremental_decoder import FairseqIncrementalDecoder
label_desc: Use image node_id 9 for calling the MultiheadAttention obj's underlying member method code with example usage: obj._append_zero_attn(k, v, key_padding_mask, attn_mask) and returns: k,  v,  key_padding_mask,  attn_mask