class_docstr: A Highway LSTM network, as used in the original Tensorflow version of the Dozat parser. Note that this
  is independent from the HLSTMCell above.
class_docstr_tok: ["A","Highway","LSTM","network",",","as","used","in","the","original","Tensorflow","version","of","the","Dozat","parser",".","Note","that","this","is","independent","from","the","HLSTMCell","above","."]
code: def forward(self, input, seqlens, hx=None):
      highway_func = (
          (lambda x: x)
          if self.highway_func is None
          else self.highway_func
      )
  
      hs = []
      cs = []
  
      if not isinstance(input, PackedSequence):
          input = pack_padded_sequence(
              input, seqlens, batch_first=self.batch_first
          )
  
      for l in range(self.num_layers):
          if l > 0:
              input = PackedSequence(
                  self.drop(input.data),
                  input.batch_sizes,
                  input.sorted_indices,
                  input.unsorted_indices,
              )
          layer_hx = (
              (
                  hx[0][
                      l
                      * self.num_directions : (l + 1)
                      * self.num_directions
                  ],
                  hx[1][
                      l
                      * self.num_directions : (l + 1)
                      * self.num_directions
                  ],
              )
              if hx is not None
              else None
          )
          h, (ht, ct) = self.lstm[l](input, seqlens, layer_hx)
  
          hs.append(ht)
          cs.append(ct)
  
          input = PackedSequence(
              h.data
              + torch.sigmoid(self.gate[l](input.data))
              * highway_func(self.highway[l](input.data)),
              input.batch_sizes,
              input.sorted_indices,
              input.unsorted_indices,
          )
  
      if self.pad:
          input = pad_packed_sequence(
              input, batch_first=self.batch_first
          )[0]
      return input, (torch.cat(hs, 0), torch.cat(cs, 0))
  
file_path: stanza/stanza/models/common/hlstm.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence, pack_sequence, PackedSequence
  from stanza.models.common.packed_lstm import PackedLSTM
label_desc: Use image node_id 2 for calling the HighwayLSTM obj's underlying member method code with example usage: obj.forward(input, seqlens, hx) and returns: input,  torch,  torch