Hi,
The issue is that tensor.dim does not have same meaning as dim in interpolation.
In case of interpolate, you need to provide a batched tensor if you are using scale_factor.
Your input [1, 4, 4] is actually a batch of 1 instance where it has 4 channels and only 1 dimension for samples but your scale_factor has 3 dimensions. That is why you see it says your input is 1D.
If you want to define an 4x4 grayscale image, you need to define your input in this way:
x = torch.rand((1, 1, 4, 4))  # (batch_size, channel, height, width)
res = F.interpolate(x, scale_factor=(2, 2), mode='nearest')
res.shape  # [1, 1, 8. 8]

And if you want to work on a 3D image (your scale_factor is 3D at least):
x = torch.rand((1, 1, 1, 4, 4))  # (batch_size, channel, height, width, depth)
res = F.interpolate(x, scale_factor=(1, 2, 2), mode='nearest')
res.shape  # torch.Size([1, 1, 1, 8, 8])

An easy solution is to always look for the source code:
def _interp_output_size(closed_over_args):  # noqa: F811
    input, size, scale_factor, recompute_scale_factor = closed_over_args
    ###############
    dim = input.dim() - 2  ############# removes batch size and channel size
    ###############
    if size is None and scale_factor is None:
        raise ValueError('either size or scale_factor should be defined')
    if size is not None and scale_factor is not None:
        raise ValueError('only one of size or scale_factor should be defined')
    if scale_factor is not None:
        if isinstance(scale_factor, (list, tuple)):
            if len(scale_factor) != dim:
                raise ValueError('scale_factor shape must match input shape. '
                                 'Input is {}D, scale_factor size is {}'.format(dim, len(scale_factor)))


Bests