title: How padded sequences given as packed sequences are dealt by RNN in pytorch?
body: <p>In pytorch, we can give a packed sequence as an input to the RNN. From <a href="http://pytorch.org/docs/master/nn.html?highlight=lstm#rnn" rel="noreferrer">official doc</a>, input of an RNN can be as follows.</p>
  
  <blockquote>
    <p><strong>input (seq_len, batch, input_size)</strong>: tensor containing the features of the input sequence. The input can also be a packed variable length sequence. </p>
  </blockquote>
  
  <p>Example</p>
  
  <pre><code>packed = torch.nn.utils.rnn.pack_padded_sequence(embedded, input_lengths)
  outputs, hidden = self.rnn(packed, hidden)
  outputs, output_lengths = torch.nn.utils.rnn.pad_packed_sequence(outputs)
  </code></pre>
  
  <p>Here, <code>embedded</code> is the embedded representation of a batch input.</p>
  
  <p>My question is, how the computation is carried out for packed sequences in RNN? How the hidden states are computed for padded sequences in a batch through packed representation?</p>