Ho,
I’m not sure there is a very clean way to do this but the following will work:
import torch

kern_size = 2

# Add 0th dimension because avg_pool expect batch dimension
inp = torch.arange(16).float().view(1, 4, 4)
pooled = torch.nn.functional.avg_pool2d(inp, kern_size)
# remove 0th dimension
pooled.squeeze_(0)
rep_col = []
for c in range(pooled.size(1)):
  col = pooled.select(1, c)
  rep_col += [col] * kern_size
repeated = torch.stack(rep_col, 1)
rep_row = []
for r in range(repeated.size(0)):
  row = repeated.select(0, r)
  rep_row += [row] * kern_size
output = torch.stack(rep_row, 0)

print(output)