Can you provide us a MRE?
It’s hard to understand what’s going on without the code.
Nevertheless, usually you get this error when the variable, beta1 in this case, can’t be computed or initialized and it’s used immediately after.
For instance, let’s suppose you have the following code:
if condition:
    beta1 = torch.something(vector ...)

loss = beta1 * SOME_LOSS_FUNCTION

If the condition is not met, you won’t be able to compute beta1, which is needed to compute the loss variable aswell.
So give a look at your code and check if the variable beta1 can be always computed.