Sorry for not being precise enough. Consider the following example module:
class Example(nn.Module):

    def __init__(self, ls):
        super(Example, self).__init__()
        self.ls = nn.Parameter(torch.full((1,), ls))

    def forward(self, X):
        # Create matrix with some cells being 
        # dependent on `self.ls` via λ=√3/self.ls
        # F = [ 0     1
        #      -λ²,  -2λ]
        λ = torch.sqrt(torch.tensor([3.])) / self.ls
        # The following line does not work (self.ls won't receive gradients)
        F = torch.tensor([[0., 1.], [-1.*λ**2, -2*λ]])

        # The following works but my question is if it is the best approach
        # since it can become tedious for larger matrices to follow this approach:
        F_0 = torch.tensor([[0., 1.]])
        F_1 = torch.tensor([[-1., -2.]]) * λ
        F_1 = F_1 * (torch.tensor([[1., 0.]]) * λ +
                            torch.tensor([[0., 1.]]))
        F = torch.cat((F_0, F_1), 0)    

        # Use F for computations with X