class_docstr: Compute attention based on dot product.
  
  Args:
      eprojs (int | None): Dimension of input vectors from encoder.
      dunits (int | None): Dimension of input vectors for decoder.
      att_dim (int): Dimension of input vectors for attention.
class_docstr_tok: ["Compute","attention","based","on","dot","product",".","Args",":","eprojs","(","int","|","None",")",":","Dimension","of","input","vectors","from","encoder",".","dunits","(","int","|","None",")",":","Dimension","of","input","vectors","for","decoder",".","att_dim","(","int",")",":","Dimension","of","input","vectors","for","attention","."]
docstr: Compute AttDot forward layer.
  
  Args:
      enc_hs (chainer.Variable | N-dimensional array):
          Input variable from encoder.
      dec_z (chainer.Variable | N-dimensional array): Input variable of decoder.
      scaling (float): Scaling weight to make attention sharp.
  
  Returns:
      chainer.Variable: Weighted sum over flames.
      chainer.Variable: Attention weight.
docstr_tok: ["Compute","AttDot","forward","layer",".","Args",":","enc_hs","(","chainer.Variable","|","N-dimensional","array",")",":","Input","variable","from","encoder",".","dec_z","(","chainer.Variable","|","N-dimensional","array",")",":","Input","variable","of","decoder",".","scaling","(","float",")",":","Scaling","weight","to","make","attention","sharp",".","Returns",":","chainer.Variable",":","Weighted","sum","over","flames",".","chainer.Variable",":","Attention","weight","."]
code: def __call__(self, enc_hs, dec_z, att_prev, scaling=2.0):
      """Compute AttDot forward layer.
  
      Args:
          enc_hs (chainer.Variable | N-dimensional array):
              Input variable from encoder.
          dec_z (chainer.Variable | N-dimensional array): Input variable of decoder.
          scaling (float): Scaling weight to make attention sharp.
  
      Returns:
          chainer.Variable: Weighted sum over flames.
          chainer.Variable: Attention weight.
  
      """
      batch = len(enc_hs)
      # pre-compute all h outside the decoder loop
      if self.pre_compute_enc_h is None:
          self.enc_h = F.pad_sequence(enc_hs)  # utt x frame x hdim
          self.h_length = self.enc_h.shape[1]
          # utt x frame x att_dim
          self.pre_compute_enc_h = F.tanh(
              self.mlp_enc(self.enc_h, n_batch_axes=2)
          )
  
      if dec_z is None:
          dec_z = chainer.Variable(
              self.xp.zeros((batch, self.dunits), dtype=np.float32)
          )
      else:
          dec_z = dec_z.reshape(batch, self.dunits)
  
      # <phi (h_t), psi (s)> for all t
      u = F.broadcast_to(
          F.expand_dims(F.tanh(self.mlp_dec(dec_z)), 1),
          self.pre_compute_enc_h.shape,
      )
      e = F.sum(self.pre_compute_enc_h * u, axis=2)  # utt x frame
      # Applying a minus-large-number filter
      # to make a probability value zero for a padded area
      # simply degrades the performance, and I gave up this implementation
      # Apply a scaling to make an attention sharp
      w = F.softmax(scaling * e)
      # weighted sum over flames
      # utt x hdim
      c = F.sum(
          self.enc_h
          * F.broadcast_to(F.expand_dims(w, 2), self.enc_h.shape),
          axis=1,
      )
  
      return c, w
  
file_path: espnet/espnet/nets/chainer_backend/rnn/attentions.py
imports: import chainer
  import chainer.functions
  import chainer.links
  import numpy
label_desc: Use image node_id 3 for calling the AttDot obj's underlying member method code with example usage: obj.__call__(enc_hs, dec_z, att_prev, scaling) and returns: c,  w