Write a function to implement a custom loss function in Python using standard libraries.
Implement the mean Huber loss for equal-length numeric sequences and return both the scalar loss and its gradient with respect to each prediction. For residual r = prediction - target, use 0.5 * r² when abs(r) <= delta, otherwise delta * (abs(r) - 0.5 * delta).
custom_loss(y_true, y_pred, delta) returns (mean_loss, gradients).
def custom_loss(y_true, y_pred, delta):