Why does pytorch prompt: RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method

Hi I have the following depreciated torch.autograd.Function code

class AdversarialLayer(torch.autograd.Function):
  def __init__(self, high_value=1.0):
    self.iter_num = 0
    self.alpha = 10
    self.low = 0.0
    self.high = high_value
    self.max_iter = 10000.0
  def forward(self, input):
    self.iter_num += 1
    output = input * 1.0
    return output

  def backward(self, gradOutput):
    self.coeff = np.float(2.0 * (self.high - self.low) / (1.0 + np.exp(-self.alpha*self.iter_num / self.max_iter)) - (self.high - self.low) + self.low)
    return -self.coeff * gradOutput

I am not sure how to update this so that I no longer get a Runtime Error. The example on the pytorch website does not address code relying on using an init function and self.

Found a solution: Custom autograd.Function: must it be static? - #3 by Megh_Bhalerao