Fix check fail in SparseApplyAdaDelta Op
C++ API `SparseApplyAdadelta` segfaults due to lack of input shape check.

Error [location](https://github.com/tensorflow/tensorflow/blob/f647f0cf7c36c7bb7ec531f11df1a028e343749a/tensorflow/core/ops/training_ops.cc#L63):


` TF_RETURN_IF_ERROR(c->Merge(c->Dim(indices, 0), c->Dim(grad, 0), &unused));
`

At `c->Dim(grad, 0)`, it reads 0th dim without checking rank of grad. Therefore when a scalar(0-rank) is given for arg grad it crashes.

The same things happen for other SparseApply* APIs(SparseApplyAdagrad, SparseApplyAdagradDA, SparseApplyFtrl, SparseApplyFtrlV2, SparseApplyMomentum, SparseApplyProximalAdagrad, SparseApplyProximalGradientDescent) as reported by the user in #62978.

Since all the above APIs calls HandleGradAndIndicesInputs , hence fixing it there might resolve the issue with all the above APIs.