Your code seems to work for a 5-dimensional input:
x = torch.randn(1, 3, 4, 5, 6)
size2=(16, 56,56)
interpolation1 = nn.Upsample(size=size2,mode='trilinear', align_corners=False)
output = interpolation1(x)