How transform outputs of maxpooling module to tensor?

Hi, I divide a learned network in submodule. output of maxpooling module is tuple and I need transform to tensor that to give next one module that have conv2d and relu. what am I doing?, 'model1.pth')
model1 = torch.load('model1.pth')

l1 = nn.Sequential(*list(model1.children())[:2]).cuda()

l2 = nn.Sequential(list(model1.children())[2]).cuda()

l3 = nn.Sequential(*list(model1.children())[3:5]).cuda()

l4 = nn.Sequential(*list(model1.children())[5:7]).cuda()

data1 = next(iter(testloader))

img2,_ = data1
img2[:,:, 45:55, 40:50]=0


y2 = torch.Tensor(y2)

this part have error:

   y2 = torch.Tensor(y2)

ValueError: only one element tensors can be converted to Python scalars


l1= Sequential(
  (0): Conv2d(3, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (1): ReLU()
l2= Sequential(
  (0): MaxPool2d(kernel_size=(2, 2), stride=(2, 2), padding=0, dilation=1, ceil_mode=False)
l3= Sequential(
  (0): Conv2d(16, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
  (1): ReLU()
l4= Sequential(
  (0): Conv2d(8, 8, kernel_size=(3, 3), stride=(1, 1))
  (1): ReLU()

I don’t think the error is due to MaxPooling because the output should be a tensor as shown in the docs: MaxPool2d — PyTorch 1.9.0 documentation

Can you post a minimal code snippet that reproduces this error or provide some details like the type of y2?

thank for your help. type is tuple. because I extract indices of maxpoolings the type was tuple.