class_docstr: Abstract class of monotonic attentions
class_docstr_tok: ["Abstract","class","of","monotonic","attentions"]
code: def __init__(self, args):
      super().__init__(
          embed_dim=args.decoder_embed_dim,
          num_heads=args.decoder_attention_heads,
          kdim=getattr(args, "encoder_embed_dim", None),
          vdim=getattr(args, "encoder_embed_dim", None),
          dropout=args.attention_dropout,
          encoder_decoder_attention=True,
      )
  
      self.soft_attention = False
  
      self.eps = getattr(args, "attention_eps", True)
      self.mass_preservation = getattr(args, "mass_preservation", True)
  
      self.noise_type = args.noise_type
      self.noise_mean = args.noise_mean
      self.noise_var = args.noise_var
  
      self.energy_bias_init = args.energy_bias_init
      self.energy_bias = (
          nn.Parameter(self.energy_bias_init * torch.ones([1]))
          if args.energy_bias is True
          else 0
      )
  
      self.k_in_proj = {"monotonic": self.k_proj}
      self.q_in_proj = {"monotonic": self.q_proj}
      self.chunk_size = None
  
imports: import math
  import torch
  from torch import Tensor
  import torch.nn
  from examples.simultaneous_translation.utils.p_choose_strategy import learnable_p_choose, waitk_p_choose
  from examples.simultaneous_translation.utils.monotonic_attention import expected_alignment_from_p_choose, expected_soft_attention, mass_preservation
  from fairseq.modules import MultiheadAttention
  from .None import register_monotonic_attention
  from typing import Dict, Optional
label_desc: Use image node_id 1 to create a new MonotonicAttention object from inherited base classes: MultiheadAttention with example: obj = MonotonicAttention(args)