def gradient(pred):
  """Compute x and y gradients.

  Args:
    pred:  L X B X H X W X C
  Returns:
    dx: x gradient
    dy: y gradient
  """
  dy = pred[:, :, 1:, :, :] - pred[:, :, :-1, :, :]
  dx = pred[:, :, :, 1:, :] - pred[:, :, :, :-1, :]
  return dx, dy