I try to TorchScript my model and it seems there is a problem while different branches possess different types. For instance in the following scenario once x is a torch.Tensor:
if a > b:
    y.append(x)
else:
    y.append(None)

I got the following error:

RuntimeError:
aten::append.t(t self, t(c → *) el) → (t):
Expected a value of type ‘t’ for argument ‘el’ but instead found type ‘None’.

Is it the case? And does anybody know a workaround for such cases?