Pytorch error: TypeError: adaptive_avg_pool3d(): argument 'output_size' (position 2) must be tuple of ints, not list
I got this error when trying to use the AdaptiveAvgPool3D in Pytorch. Below is the error trace
Traceback (most recent call last):

File &quot;/scratch/a.bip5/BraTS 2021/./sisa.py&quot;, line 395, in 
outputs = model(inputs)
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/modules/module.py&quot;, line 1051, in _call_impl
return forward_call(*input, **kwargs)
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/parallel/data_parallel.py&quot;, line 166, in forward
return self.module(*inputs[0], **kwargs[0])
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/modules/module.py&quot;, line 1051, in _call_impl
return forward_call(*input, **kwargs)
File &quot;/scratch/a.bip5/BraTS 2021/./sisa.py&quot;, line 96, in forward
x1 = self.pool1(x)
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/modules/module.py&quot;, line 1051, in _call_impl
return forward_call(*input, **kwargs)
File &quot;/scratch/a.bip5/BraTS 2021/./sisa.py&quot;, line 135, in forward
x1=aa(x)
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/modules/module.py&quot;, line 1051, in _call_impl
return forward_call(*input, **kwargs)
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/modules/pooling.py&quot;, line 1166, in forward
return F.adaptive_avg_pool3d(input, self.output_size)
File &quot;/home/a.bip5/.conda/envs/pix2pix/lib/python3.9/site-packages/torch/nn/functional.py&quot;, line 1148, in adaptive_avg_pool3d
return torch._C._nn.adaptive_avg_pool3d(input, _output_size)
TypeError: adaptive_avg_pool3d(): argument 'output_size' (position 2) must be tuple of ints, not list
When looking into the error stack I found this piece of code in ../functional.py:
if has_torch_function_unary(input):
    return handle_torch_function(
        adaptive_max_pool3d_with_indices, (input,), input, output_size, return_indices=return_indices
    )
_output_size = _list_with_default(output_size, input.size())
return torch._C._nn.adaptive_max_pool3d(input, _output_size)

Printing out types for output_size and _output_size shows one's a tuple(as it is supposed to be) and the other is turned into a list before being passed through in the lib function itself. What I don't understand is why this conversion to list is taking place if the function using this list doesn't like it? If the purpose of this is to give out an error, what are the conditions that satisfy the has_torch_function_unary condition?
Any help would be appreciated.
Edit:
I tried to side-step the problem by using output_size in the final return statement instead of _output_size. That led to an even more cryptic error-
TypeError: adaptive_avg_pool3d(): argument 'output_size' (position 2) must be tuple of ints, not tuple
How does pytorch differentiate between tuple of ints and a tuple?

The reason behind the error turned out to be a type error. When passing the size to AdaptiveAvgPool3d I was getting the values for the size through division. Although the remainder was 0, division by default saves values as float in python. This meant the tuple being passed as the output_size was in fact a tuple of float which the _list_with_default turns into a list but likely doesn't if the tuple was made of int. Simply using int(..) for each dimension passed to AdaptiveAvgPool3d was the solution.
