The buffer self.grad = g installs.
The gradient slot is a bare Storage, read as self's dtype, device and
shape; g must have all three — checked in that order, as the reference
does — and may not be self. A hook's returned gradient passes the same
checks against the gradient it replaces.
Raises
DtypeMismatch, DeviceMismatch, ShapeMismatchg is of another kind.LucidErrorg is self, or a Metal strided view with no buffer of its own.