'Compute the gradients of this NDArray w.r.t variables.
Parameters
out_grad : NDArray, optional
Gradient with respect to head.
retain_graph : bool, optional
Whether to retain the computaion graph for another backward
pass on the same graph. By default the computaion history
is cleared.
train_mode : bool, optional
Whether to compute gradient for training or inference.'

def backward(self, out_grad=None, retain_graph=False, train_mode=True):

    if (out_grad is None):
        ograd_handles = [NDArrayHandle(0)]
    else:
        ograd_handles = [out_grad.handle]
    check_call(_LIB.MXAutogradBackwardEx(1, c_array(NDArrayHandle, [self.handle]), c_array(NDArrayHandle, ograd_handles), ctypes.c_int(retain_graph), ctypes.c_int(train_mode)))
