class_docstr: This class implements content-based attention module for seq2seq
  learning.
  
  Reference: NEURAL MACHINE TRANSLATION BY JOINTLY LEARNING TO ALIGN
  AND TRANSLATE, Bahdanau et.al. https://arxiv.org/pdf/1409.0473.pdf
  
  Arguments
  ---------
  attn_dim : int
      Size of the attention feature.
  output_dim : int
      Size of the output context vector.
  scaling : float
      The factor controls the sharpening degree (default: 1.0).
  
  Example
  -------
  >>> enc_tensor = torch.rand([4, 10, 20])
  >>> enc_len = torch.ones([4]) * 10
  >>> dec_tensor = torch.rand([4, 25])
  >>> net = ContentBasedAttention(enc_dim=20, dec_dim=25, attn_dim=30, output_dim=5)
  >>> out_tensor, out_weight = net(enc_tensor, enc_len, dec_tensor)
  >>> out_tensor.shape
  torch.Size([4, 5])
code: def __init__(
      self, enc_dim, dec_dim, attn_dim, output_dim, scaling=1.0
  ):
      super(ContentBasedAttention, self).__init__()
  
      self.mlp_enc = nn.Linear(enc_dim, attn_dim)
      self.mlp_dec = nn.Linear(dec_dim, attn_dim)
      self.mlp_attn = nn.Linear(attn_dim, 1, bias=False)
      self.mlp_out = nn.Linear(enc_dim, output_dim)
  
      self.scaling = scaling
  
      self.softmax = nn.Softmax(dim=-1)
  
      # reset the encoder states, lengths and masks
      self.reset()
  
imports: import torch
  import logging
  import torch.nn
  import numpy
  from typing import Optional
  from speechbrain.dataio.dataio import length_to_mask
  import torch.nn.functional
  import math
label_desc: Use image node_id 1 to create a new ContentBasedAttention object from inherited base classes: nn with example: obj = ContentBasedAttention(enc_dim, dec_dim, attn_dim, output_dim, scaling)