class_docstr: AWD-LSTM inspired by https://arxiv.org/abs/1708.02182
class_docstr_tok: ["AWD-LSTM","inspired","by","https",":","\/\/arxiv.org\/abs\/1708.02182"]
code: def forward(self, inp: Tensor, from_embeds: bool = False):
      bs, sl = inp.shape[:2] if from_embeds else inp.shape
      if bs != self.bs:
          self._change_hidden(bs)
  
      output = self.input_dp(
          inp if from_embeds else self.encoder_dp(inp)
      )
      new_hidden = []
      for l, (rnn, hid_dp) in enumerate(
          zip(self.rnns, self.hidden_dps)
      ):
          output, new_h = rnn(output, self.hidden[l])
          new_hidden.append(new_h)
          if l != self.n_layers - 1:
              output = hid_dp(output)
      self.hidden = to_detach(new_hidden, cpu=False, gather=False)
      return output
  
imports: from __future__ import annotations
  from ...data.all import *
  from ..core import *
label_desc: Use image node_id 2 for calling the AWD_LSTM obj's underlying member method code with example usage: obj.forward(inp, from_embeds) and returns: output