Calling lstm.flatten_parameters() in torch.jit.script_method

I’m getting the error below when calling flatten_parameters on a lstm inside script_method inside a ScriptModule

RuntimeError:
attribute 'flatten_parameters' of type 'NoneType' is not usable in a script method (did you forget to add it __constants__?):
@torch.jit.script_method
def inference(self, x):
    for conv in self.convolutions:
        x = F.dropout(F.relu(conv(x)), 0.5, False)

    x = x.transpose(1, 2)

    self.lstm.flatten_parameters()
    ~~~~~~~~~~~~~~~~~ <--- HERE