I found that:
if I define as class fun() instead of class fun(torch.autograd.Function):
the autoreload succeed.
Also I try following , the autoreload works for both sequences.
import torch
import torch.nn as nn
import torch.nn.functional as F

class fun(torch.autograd.Function):

    @staticmethod
    def forward(ctx, input):
        ctx.save_for_backward(input)
        return input.gt(thresh).float()

    @staticmethod
    def backward(ctx, grad_output):
        input, = ctx.saved_tensors
        grad_input = grad_output.clone()
        temp = abs(input - thresh) < lens
        return grad_input * temp.float()

class Dummy():
    print("torch")

`