Solved by KFrank in post #2 
              
              
                Hi NPC! 

To me the conceptually cleanest approach would be to build your 
constrained kernel from a separate two-element Parameter that 
you actually optimize.  Something like: 
import torch
from itertools import chain

# initialize  a = 1.1, b = 2.2
k = torch.nn.Parameter (torch.tensor ([1.1, 2.2]…