class_docstr: Average attention.
  See "Accelerating Neural Transformer via an Average Attention Network"
  for more details.
code: def _forward(self, value, mask_trick, mask_future_timesteps):
      length, batch_size = value.size()[:2]
      if not mask_future_timesteps:
          attn = value.mean(dim=0, keepdim=True).repeat(length, 1, 1)
          attn_weights = None
      elif mask_trick:
          v = value.transpose(0, 1)
          attn_weights = torch.arange(
              1, length + 1, out=v.new(), requires_grad=False
          )
          attn_weights = (
              attn_weights.reciprocal_()
              .unsqueeze_(1)
              .repeat(1, length)
              .tril(0)
          )
          attn_weights = attn_weights.unsqueeze_(0).repeat(
              batch_size, 1, 1
          )
          attn_weights = F.dropout(
              attn_weights, p=self.dropout, training=self.training
          )
          attn = torch.bmm(attn_weights, v)
          attn = attn.transpose(0, 1).contiguous()
      else:
          batch_size = value.size()
          attn_weights = torch.arange(
              1, length + 1, out=value.new(), requires_grad=False
          ).view(length, 1, 1)
          attn = value.cumsum(0) / attn_weights
          attn_weights = None
      return attn, attn_weights
  
imports: import torch
  import torch.nn.functional
  from fairseq import utils
  from fairseq.incremental_decoding_utils import with_incremental_state
  from torch import nn
label_desc: Use image node_id 3 for calling the AverageAttention obj's underlying member method code with example usage: obj._forward(value, mask_trick, mask_future_timesteps) and returns: attn,  attn_weights