class_docstr: __init__(self, n_layers, in_size, out_size, dropout)
  
  Stacked Uni-directional LSTM for sequences.
  
  This link is stacked version of Uni-directional LSTM for sequences.
  It calculates hidden and cell states of all layer at end-of-string,
  and all hidden states of the last layer for each time.
  
  Unlike :func:`chainer.functions.n_step_lstm`, this function automatically
  sort inputs in descending order by length, and transpose the sequence.
  Users just need to call the link with a list of :class:`chainer.Variable`
  holding sequences.
  
  Args:
      n_layers (int): Number of layers.
      in_size (int): Dimensionality of input vectors.
      out_size (int): Dimensionality of hidden states and output vectors.
      dropout (float): Dropout ratio.
  
  .. seealso::
      :func:`chainer.functions.n_step_lstm`
  
  .. admonition:: Example
  
      *Read* :meth:`forward` *method below first.*
  
      >>> dropout_ratio = 0.0
      >>> in_size, seq_len, n_layers, out_size = 2, 4, 2, 3
      >>> batch = 5
      >>> xs = [
      ...     Variable(np.random.rand(seq_len, in_size).astype(np.float32))
      ...     for i in range(batch)]
      >>> [x.shape for x in xs]
      [(4, 2), (4, 2), (4, 2), (4, 2), (4, 2)]
      >>> lstm = L.NStepLSTM(n_layers, in_size, out_size, dropout_ratio)
  
      Without hidden or cell state:
  
      >>> hy, cy, ys = lstm(None, None, xs)
      >>> hy.shape  # shape should be (n_layers, batch, out_size)
      (2, 5, 3)
      >>> ys[0].shape  # should be (seq_len, out_size)
      (4, 3)
      >>> len(ys)  # should be equal to batch
      5
  
      With hidden and cell states:
  
      >>> h_shape = (n_layers, batch, out_size)
      >>> hx = Variable(np.ones(h_shape, np.float32))
      >>> cx = Variable(np.ones(h_shape, np.float32))
      >>> hy, cy, ys = lstm(hx, cx, xs)
      >>> hy.shape  # shape should be (n_layers, batch, out_size)
      (2, 5, 3)
      >>> ys[0].shape  # should be (seq_len, out_size)
      (4, 3)
class_docstr_tok: ["__init__","(","self",",","n_layers",",","in_size",",","out_size",",","dropout",")","Stacked","Uni-directional","LSTM","for","sequences",".","This","link","is","stacked","version","of","Uni-directional","LSTM","for","sequences",".","It","calculates","hidden","and","cell","states","of","all","layer","at","end-of-string",",","and","all","hidden","states","of","the","last","layer","for","each","time",".","Unlike",":","func",":","`","chainer.functions.n_step_lstm","`",",","this","function","automatically","sort","inputs","in","descending","order","by","length",",","and","transpose","the","sequence",".","Users","just","need","to","call","the","link","with","a","list","of",":","class",":","`","chainer.Variable","`","holding","sequences",".","Args",":","n_layers","(","int",")",":","Number","of","layers",".","in_size","(","int",")",":","Dimensionality","of","input","vectors",".","out_size","(","int",")",":","Dimensionality","of","hidden","states","and","output","vectors",".","dropout","(","float",")",":","Dropout","ratio",".","..","seealso",":",":",":","func",":","`","chainer.functions.n_step_lstm","`","..","admonition",":",":","Example","*","Read","*",":","meth",":","`","forward","`","*","method","below","first",".","*",">",">",">","dropout_ratio","=","0.0",">",">",">","in_size",",","seq_len",",","n_layers",",","out_size","=","2",",","4",",","2",",","3",">",">",">","batch","=","5",">",">",">","xs","=","[","...","Variable","(","np.random.rand","(","seq_len",",","in_size",")",".astype","(","np.float32",")",")","...","for","i","in","range","(","batch",")","]",">",">",">","[","x.shape","for","x","in","xs","]","[","(","4",",","2",")",",","(","4",",","2",")",",","(","4",",","2",")",",","(","4",",","2",")",",","(","4",",","2",")","]",">",">",">","lstm","=","L.NStepLSTM","(","n_layers",",","in_size",",","out_size",",","dropout_ratio",")","Without","hidden","or","cell","state",":",">",">",">","hy",",","cy",",","ys","=","lstm","(","None",",","None",",","xs",")",">",">",">","hy.shape","#","shape","should","be","(","n_layers",",","batch",",","out_size",")","(","2",",","5",",","3",")",">",">",">","ys","[","0","]",".shape","#","should","be","(","seq_len",",","out_size",")","(","4",",","3",")",">",">",">","len","(","ys",")","#","should","be","equal","to","batch","5","With","hidden","and","cell","states",":",">",">",">","h_shape","=","(","n_layers",",","batch",",","out_size",")",">",">",">","hx","=","Variable","(","np.ones","(","h_shape",",","np.float32",")",")",">",">",">","cx","=","Variable","(","np.ones","(","h_shape",",","np.float32",")",")",">",">",">","hy",",","cy",",","ys","=","lstm","(","hx",",","cx",",","xs",")",">",">",">","hy.shape","#","shape","should","be","(","n_layers",",","batch",",","out_size",")","(","2",",","5",",","3",")",">",">",">","ys","[","0","]",".shape","#","should","be","(","seq_len",",","out_size",")","(","4",",","3",")"]
code: def n_cells(self):
      return 2
  
file_path: chainer/chainer/links/rnn/n_step_lstm.py
imports: from chainer.functions.rnn import n_step_lstm
  from chainer.links.rnn import n_step_rnn
label_desc: Use image node_id 2 for calling the NStepLSTM obj's underlying member method code with example usage: obj.n_cells() and returns: int