# Buggy code
def __init__(
    self,
    model,
    inducing_points,
    variational_distribution,
    learn_inducing_locations=False,
):
    """
    Args:
        model (:obj:`gpytorch.model.AbstractVariationalGP`): Model this strategy is applied to. Typically passed in
        when the VariationalStrategy is created in the __init__ method of the user defined model.
        inducing_points (torch.tensor): Tensor containing a set of inducing points to use for variational inference.
        variational_distribution (:obj:`gpytorch.variational.VariationalDistribution`): A VariationalDistribution
            object that represents the form of the variational distribution :math:`q(u)`
        learn_inducing_locations (bool): Whether or not the inducing point locations should be learned (e.g. SVGP).
    """
    super(VariationalStrategy, self).__init__()
    object.__setattr__(self, "model", model)

    inducing_points = inducing_points.clone()

    if inducing_points.dim() == 1:
        inducing_points = inducing_points.unsqueeze(-1)

    if learn_inducing_locations:
        self.register_parameter(
            name="inducing_points", parameter=torch.nn.Parameter(inducing_points)
        )
    else:
        self.register_buffer("inducing_points", inducing_points)

    self.variational_distribution = variational_distribution
    self.register_buffer("variational_params_initialized", torch.tensor(0))


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-c955f39ee560> in <module>
4 with torch.no_grad():
5     for x_batch, y_batch in test_loader:
----> 6         preds = model(x_batch)
7         means = torch.cat([means, preds.mean.cpu()])
8 means = means[1:]

~/miniconda3/envs/mbrl/lib/python3.7/site-packages/gpytorch/models/abstract_variational_gp.py in __call__(self, inputs, **kwargs)
20             inputs = inputs.unsqueeze(-1)
21
---> 22         return self.variational_strategy(inputs)

~/miniconda3/envs/mbrl/lib/python3.7/site-packages/gpytorch/variational/variational_strategy.py in __call__(self, x)
228                 self._memoize_cache = dict()
229
--> 230         return super(VariationalStrategy, self).__call__(x)

~/miniconda3/envs/mbrl/lib/python3.7/site-packages/gpytorch/module.py in __call__(self, *inputs, **kwargs)
20
21     def __call__(self, *inputs, **kwargs):
---> 22         outputs = self.forward(*inputs, **kwargs)
23         if isinstance(outputs, list):
24             return [_validate_module_outputs(output) for output in outputs]

~/miniconda3/envs/mbrl/lib/python3.7/site-packages/gpytorch/variational/variational_strategy.py in forward(self, x)
214                     induc_induc_covar.inv_matmul(induc_data_covar)
215                 )
--> 216                 data_covariance = data_data_covar + neg_induc_data_data_covar
217             predictive_covar = PsdSumLazyTensor(predictive_covar, data_covariance)
218

~/miniconda3/envs/mbrl/lib/python3.7/site-packages/gpytorch/lazy/sum_lazy_tensor.py in __add__(self, other)
75             return SumLazyTensor(*(list(self.lazy_tensors) + [other]))
76         else:
---> 77             raise AttributeError("other must be a LazyTensor")
78
79     def diag(self):

AttributeError: other must be a LazyTensor

# Fixed code
def __init__(
    self,
    model,
    inducing_points,
    variational_distribution,
    learn_inducing_locations=True,
):
    super().__init__(
        model, inducing_points, variational_distribution, learn_inducing_locations
    )
    self.register_buffer("updated_strategy", torch.tensor(True))
    self._register_load_state_dict_pre_hook(_ensure_updated_strategy_flag_set)