How to assert torch.float32/64 using isinstance?
I am writing a pipeline for my deep learning project, as a good practice, I try to do some assertions to make sure the data type matches, so it's easier to debug later! However, I do not know how to use isinstance to assert the torch.Tensor's dtype.
For example:
    assert isinstance(image, torch.Tensor) and isinstance(target['boxes'], torch.Tensor)
    assert isinstance(image.dtype, (torch.float32, torch.float64)) and isinstance(target['boxes'].dtype, (torch.float32, torch.float64)) 

Is using assert image.dtype in [torch.float32, torch.float64] the only method here? Is there an elegant way to do so?

You could use torch.is_floating_point
assert torch.is_floating_point(image) and torch.is_floating_point(target['boxes'])

The function raises an exception if the input is not a tensor. Therefore it is not necessary to do an independent check for torch.Tensor.
