def forward_backward(self, x):
with mx.autograd.record():<EOL><INDENT>(ls, next_sentence_label, classified, masked_id, decoded,masked_weight, ls1, ls2, valid_length) = forward(x, self._model, self._mlm_loss,<EOL>self._nsp_loss, self._vocab_size,<EOL>args.dtype)<EOL>ls = ls / self._rescale_factor<EOL><DEDENT>if args.dtype == '<STR_LIT>':<EOL><INDENT>self._trainer.backward(ls)<EOL><DEDENT>else:<EOL><INDENT>ls.backward()<EOL><DEDENT>return ls, next_sentence_label, classified, masked_id, decoded,masked_weight, ls1, ls2, valid_length<EOL>
forward backward implementation