(self, x, h)
return last_h, h_list
Args:
            x: [batch_size, input_size]
            h: [num_layers, batch_size, hidden_size]
        Return:
            last_h: [batch_size, hidden_size] (h from last layer)
            h_list: [num_layers, batch_size, hidden_size] (h from all layers)
Args:
            x: [batch_size, input_size]
            h: [num_layers, batch_size, hidden_size]
        Return:
            last_h: [batch_size, hidden_size] (h from last layer)
            h_list: [num_layers, batch_size, hidden_size] (h from all layers)
Args : x : [ batch_size input_size ] h : [ num_layers batch_size hidden_size ] Return : last_h : [ batch_size hidden_size ] ( h from last layer ) h_list : [ num_layers batch_size hidden_size ] ( h from all layers )
def forward(self, x, h):
        """
        Args:
            x: [batch_size, input_size]
            h: [num_layers, batch_size, hidden_size]
        Return:
            last_h: [batch_size, hidden_size] (h from last layer)
            h_list: [num_layers, batch_size, hidden_size] (h from all layers)
        """
        # h of all layers
        h_list = []
        for i, layer in enumerate(self.layers):
            # h of i-th layer
            h_i = layer(x, h[i])

            # x for next layer
            x = h_i
            if i + 1 is not self.num_layers:
                x = self.dropout(x)
            h_list.append(h_i)

        last_h = h_list[-1]
        h_list = torch.stack(h_list)

        return last_h, h_list
def forward ( self , x , h ) : # h of all layers h_list = [ ] for i , layer in enumerate ( self . layers ) : # h of i-th layer h_i = layer ( x , h [ i ] ) # x for next layer x = h_i if i + 1 is not self . num_layers : x = self . dropout ( x ) h_list . append ( h_i ) last_h = h_list [ - 1 ] h_list = torch . stack ( h_list ) return last_h , h_list