Behavior of trilinear interpolation when input and output depth are the same

I would like to upsample a 5D tensor using the trilinear mode with torch.nn.Upsample. Specifically, I want to resize only the last two dimensions (H, W).

I have heard that trilinear interpolation typically uses depth information for interpolation. So my question is: If the depth remains the same between the input and the output tensor, does the trilinear mode still influence the depth dimension in any way, or is the upsampling performed independently for each depth slice?

Here is an example script to illustrate my question:

b, c, d, h, w = 1, 10, 3, 10, 20
trg_h, trg_w = 20, 40
tensor_5d = torch.randn(b, c, d, h, w)
upsample = torch.nn.Upsample(size=(d, trg_h, trg_w), mode='trilinear')
# or upsample = torch.nn.Upsample(scale_factor=(1, 2, 2), mode='trilinear')
tensor_5d_up = upsample(tensor_5d)