First thing is that you can’t return a Variable from forward - it expects tensors and will automatically wrap them in Variables and connect them up to the existing graph. You shouldn’t unpack and re-pack Variables in the middle of computation, because that will break continuity of history. You need to do something like that:
def my_criterion(input, target, epoch, isLabeled):
    if (isLabeled.data > 0).all():
        return loss * alpha * epoch
    return MyCriterion()(input, target, epoch, isLabeled)

Another thing. You should never call the forward method directly. You should instantiate the Function class and call it like you’d call a function. You can use the function I provided as a more convenient wrapper.
I’d recommend reading notes about extending autograd 96.