'Constructs forward and reverse LM graphs from inputs to LM losses.
* Caches the VatxtInput objects in `self.lm_inputs`
* Caches tensors: `lm_embedded`, `lm_embedded_reverse`
Args:
compute_loss: bool, whether to compute and return the loss or stop after
the LSTM computation.
Returns:
loss: scalar float, sum of forward and reverse losses.'

def language_model_graph(self, compute_loss=True):

    inputs = _inputs('train', pretrain=True, bidir=True)
    self.lm_inputs = inputs
    (f_inputs, r_inputs) = inputs
    f_loss = self._lm_loss(f_inputs, compute_loss=compute_loss)
    r_loss = self._lm_loss(r_inputs, emb_key='lm_embedded_reverse', lstm_layer='lstm_reverse', lm_loss_layer='lm_loss_reverse', loss_name='lm_loss_reverse', compute_loss=compute_loss)
    if compute_loss:
        return (f_loss + r_loss)
