Older implementations of Pytorch treat a TensorImage and Tensor as though it is the same in terms of doing operations (duck typing). The newest implementation will insist that the types have been specified even if the two objects are compatible (multiple dispatch I guess).
My question is how do I get old code to work i.e. convert a TensorImage or TensorMultiCategory to a plain a Tensor in a loss or forward function.
A quick fix is to just use torch.tensor(tensor_image) but this creates a warning:
UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).

Using this recommendation or torch.as_tensor does not work, the object e.g. TensorImage does not get converted to a Tensor, it just gets cloned.
Is there a cleaner way of solving this?