class_docstr: Encoder.
  
  Args:
      input_type(str):
          Sampling type. `input_type` must be `conv2d` or 'linear' currently.
      idim (int): Dimension of inputs.
      n_layers (int): Number of encoder layers.
      n_units (int): Number of input/output dimension of a FeedForward layer.
      d_units (int): Number of units of hidden layer in a FeedForward layer.
      h (int): Number of attention heads.
      dropout (float): Dropout rate
class_docstr_tok: ["Encoder",".","Args",":","input_type","(","str",")",":","Sampling","type",".","`","input_type","`","must","be","`","conv2d","`","or","'linear","'","currently",".","idim","(","int",")",":","Dimension","of","inputs",".","n_layers","(","int",")",":","Number","of","encoder","layers",".","n_units","(","int",")",":","Number","of","input\/output","dimension","of","a","FeedForward","layer",".","d_units","(","int",")",":","Number","of","units","of","hidden","layer","in","a","FeedForward","layer",".","h","(","int",")",":","Number","of","attention","heads",".","dropout","(","float",")",":","Dropout","rate"]
docstr: Compute Encoder layer.
  
  Args:
      e (chainer.Variable): Batch of padded character. (B, Tmax)
      ilens (chainer.Variable): Batch of length of each input batch. (B,)
  
  Returns:
      chainer.Variable: Computed variable of encoder.
      numpy.array: Mask.
      chainer.Variable: Batch of lengths of each encoder outputs.
docstr_tok: ["Compute","Encoder","layer",".","Args",":","e","(","chainer.Variable",")",":","Batch","of","padded","character",".","(","B",",","Tmax",")","ilens","(","chainer.Variable",")",":","Batch","of","length","of","each","input","batch",".","(","B",",",")","Returns",":","chainer.Variable",":","Computed","variable","of","encoder",".","numpy.array",":","Mask",".","chainer.Variable",":","Batch","of","lengths","of","each","encoder","outputs","."]
code: def forward(self, e, ilens):
      """Compute Encoder layer.
  
      Args:
          e (chainer.Variable): Batch of padded character. (B, Tmax)
          ilens (chainer.Variable): Batch of length of each input batch. (B,)
  
      Returns:
          chainer.Variable: Computed variable of encoder.
          numpy.array: Mask.
          chainer.Variable: Batch of lengths of each encoder outputs.
  
      """
      if isinstance(self.input_layer, Conv2dSubsampling):
          e, ilens = self.input_layer(e, ilens)
      else:
          e = self.input_layer(e)
      batch, length, dims = e.shape
      x_mask = np.ones([batch, length])
      for j in range(batch):
          x_mask[j, ilens[j] :] = -1
      xx_mask = (x_mask[:, None, :] >= 0) * (x_mask[:, :, None] >= 0)
      xx_mask = self.xp.array(xx_mask)
      if self.do_history_mask:
          history_mask = make_history_mask(self.xp, x_mask)
          xx_mask *= history_mask
      logging.debug("encoders size: " + str(e.shape))
      e = e.reshape(-1, dims)
      for i in range(self.n_layers):
          e = self["encoders." + str(i)](e, xx_mask, batch)
      return self.norm(e).reshape(batch, length, -1), x_mask, ilens
  
file_path: espnet/espnet/nets/chainer_backend/transformer/encoder.py
imports: import logging
  import chainer
  import numpy
  from chainer import links
  from espnet.nets.chainer_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.chainer_backend.transformer.encoder_layer import EncoderLayer
  from espnet.nets.chainer_backend.transformer.layer_norm import LayerNorm
  from espnet.nets.chainer_backend.transformer.mask import make_history_mask
  from espnet.nets.chainer_backend.transformer.subsampling import Conv2dSubsampling, LinearSampling
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.forward(e, ilens) and returns: self,  x_mask,  ilens