LSTM source code question

Hi

I am trying to make customized LSTM cell but have some problems with figuring out what the really output is.

From the source code, it seems like returned value of output and permute_hidden value.

And output and hidden values are from result.

I am wondering the what result means and where the result is coming from.

        if batch_sizes is None:
            result = _VF.lstm(input, hx, self._flat_weights, self.bias, self.num_layers,
                              self.dropout, self.training, self.bidirectional, self.batch_first)
        else:
            result = _VF.lstm(input, batch_sizes, hx, self._flat_weights, self.bias,
                              self.num_layers, self.dropout, self.training, self.bidirectional)
        output = result[0]
        hidden = result[1:]
        # xxx: isinstance check needs to be in conditional for TorchScript to compile
        if isinstance(orig_input, PackedSequence):
            output_packed = PackedSequence(output, batch_sizes, sorted_indices, unsorted_indices)
            return output_packed, self.permute_hidden(hidden, unsorted_indices)
        else:
            return output, self.permute_hidden(hidden, unsorted_indices)

Any help or comments would be appriciated!

Thank you!

Depending on which implementation and device you are using I assume the result is created in one of these methods.

I am trying to understand what result means and how they are separated into output and hidden value!

Since as far as I know the output of the LSTM is hidden and cell states continuously, but wondering how output is made of.