Hello @ptrblck, I really appreciate that you are taking a look into this. Thank you so much.
So, here is a code snippet for reproducing it.
import torch

def my_not_so_secrete_function(Y, _Y):
  p = Y.shape[-2] - Y.shape[-1]
  padding = (0, p)
  m = Y.shape[-1]

  Y = torch.nn.functional.pad(Y, padding)
  if Y.ndim == 5:
    Y[:, :, :,  0, m:] = _Y[:, :, :, 0, 1:1+p].flip([-1])
    Y[:, :, :, 1:, m:] = _Y[:, :, :, 1:, 1:1+p].flip([-2, -1]);
  elif Y.ndim == 4:
    Y[:, :,  0, m:] = _Y[ :, :, 0, 1:1+p].flip([-1])
    Y[:, :, 1:, m:] = _Y[ :, :, 1:, 1:1+p].flip([-2, -1]);
  else:
    raise ValueError('Wrong Shape for Y')

  return Y

device = torch.device('cuda' if torch.cuda.is_available else 'cpu')
with torch.profiler.profile(
   record_shapes=True
) as profile:
  for _ in range(8):
    Y = torch.randint(32, size=(128, 64, 3, 32, 17), dtype=torch.float, device=device)
    _Y = torch.randint(32, size=(128, 64, 3, 32, 17), dtype=torch.float, device=device)
    output = my_not_so_secrete_function(Y, _Y)

profile.export_chrome_trace('profile-investigation.json')

I uploaded the profile-investigation.json file here as a Github Gist.