Add ability to compute gradients in datasets.