Create torch.Tensor from Optional[torch.Tensor] in jit.script

Hello, I have an optional torch.Tensor that should be processed with standard functional functions (e.g. torch.nn.functional.interpolate). When I try to write condition like: if tensor is not None: x = F.interpolate(x), I’ve got error like “Expected a value of type ‘Tensor’ for argument ‘input’ but instead found type ‘Optional[Tensor]’”. When I try to do something like new_x: torch.Tensor = x.clone() , I’ve got the error like “‘Optional[Tensor]’ object has no attribute or method ‘clone’” . How can I cast optional tensor to tensor when I’m sure it is not Null?