Repository: cornellius-gp/gpytorch
Issue: [Bug] inplace operation in RBFKernelGrad when diag=True

# 🐛 Bug

RBFKernelGrad uses an inplace operation when diag=True that breaks backward.

## To reproduce

```python
import torch
from gpytorch.kernels import RBFKernelGrad

# This works
k = RBFKernelGrad()
train_x=torch.tensor([1., 2., 3.])
z = k(train_x, train_x)
z[0, 0].backward()
print(k.raw_lengthscale.grad)

# This fails
z = k(train_x, train_x, diag=True)
z[0].backward()
print(k.raw_lengthscale.grad)
```

** Stack trace/error message **
```
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-17-ecb6525006fe> in <module>
      1 z = k(train_x, train_x, diag=True)
----> 2 z[0].backward()
      3 print(k.raw_lengthscale.grad)

/mnt/xarfuse/uid-66331/be3771ae-seed-nspid4026531836-ns-4026531840/torch/tensor.py in backward(self, gradient, retain_graph, create_graph, inputs)
    231                 create_graph=create_graph,
    232                 inputs=inputs)
--> 233         torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
    234 
    235     def register_hook(self, hook):

/mnt/xarfuse/uid-66331/be3771ae-seed-nspid4026531836-ns-4026531840/torch/autograd/__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables, inputs)
    144     Variable._execution_engine.run_backward(
    145         tensors, grad_tensors_, retain_graph, create_graph, inputs,
--> 146         allow_unreachable=True, accumulate_grad=True)  # allow_unreachable flag
    147 
    148 

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [1, 1]], which is output 0 of SoftplusBackward, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
```

## Expected Behavior

Same as what happens without `diag=True`.

## System information

**Please complete the following information:**
- GPyTorch Version 1.3.0
- PyTorch Version 1.7.1
- Linux

Changed files:
gpytorch/kernels/rbf_kernel_grad.py

diff --git a/gpytorch/kernels/rbf_kernel_grad.py b/gpytorch/kernels/rbf_kernel_grad.py
index dc60cd2b..568bc280 100644
--- a/gpytorch/kernels/rbf_kernel_grad.py
+++ b/gpytorch/kernels/rbf_kernel_grad.py
@@ -108,7 +108,7 @@ class RBFKernelGrad(RBFKernel):
                 raise RuntimeError("diag=True only works when x1 == x2")
 
             kernel_diag = super(RBFKernelGrad, self).forward(x1, x2, diag=True)
-            grad_diag = torch.ones(*batch_shape, n2, d, device=x1.device, dtype=x1.dtype) / self.lengthscale.pow_(2)
+            grad_diag = torch.ones(*batch_shape, n2, d, device=x1.device, dtype=x1.dtype) / self.lengthscale.pow(2)
             grad_diag = grad_diag.transpose(-1, -2).reshape(*batch_shape, n2 * d)
             k_diag = torch.cat((kernel_diag, grad_diag), dim=-1)
             pi = torch.arange(n2 * (d + 1)).view(d + 1, n2).t().reshape((n2 * (d + 1)))