Earlier I was saving in the list so that was creating an issue … my bad…now I am saving it directly in file as tensor.
def train_model():
    for epoch in range(num_epochs+1):
        for data in dataloader:
           img,target = data
           if epoch == num_epochs:
               x_comp,output = model(img,return_comp=True)
               #X_comp.append(x_comp)
               #label.append(target)
               torch.save(target, './target.pt')
               torch.save(x_comp, './x_comp.pt')
           else:
               output = model(img)
           loss = criterion(output, img)
           optimizer.zero_grad()
           loss.backward()
           optimizer.step()

This is how I am saving it.
Shape of tensors are
for target
torch.Size([6, 3, 224, 224])

for x_comp
torch.Size([6, 4, 56, 56])

And below is the CNN that I am using to do classification where I have freezed the convolutional layers and using only FC layers.
class ConvNet(nn.Module):
    def __init__(self):
        super(ConvNet, self).__init__()
        
        self.conv1 = nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2)
        self.pool1 = nn.MaxPool2d(kernel_size=3, stride=2)
        
        self.conv2 = nn.Conv2d(64, 192, kernel_size=5, padding=2)
        self.pool2 = nn.MaxPool2d(kernel_size=3, stride=2)
        
        
        self.conv3 = nn.Conv2d(192, 384, kernel_size=3, padding=1)
        self.conv4 = nn.Conv2d(384, 256, kernel_size=3, padding=1)
        
        self.conv5 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
        self.pool5 = nn.MaxPool2d(kernel_size=3, stride=2)
        
        self.relu = nn.ReLU()
        
        self.drop_out = nn.Dropout()
        self.fc1 = nn.Linear(6 * 6 * 256, 4096)
        self.fc2 = nn.Linear(4096, 4096)
        self.fc3 = nn.Linear(4096, 1)
        self.relu = nn.ReLU()
        self.sigmoid = nn.Sigmoid()

    def forward(self, x):
        out = self.pool1(self.relu(self.conv1(x)))
        out = self.pool2(self.relu(self.conv2(out)))
        out = self.relu(self.conv3(out))
        out = self.relu(self.conv4(out))
        out = self.pool5(self.relu(self.conv5(out)))
        out = out.reshape(out.size(0), -1)
        
        #out = self.drop_out(out)
        out = self.drop_out(out)
        out = self.relu(self.fc1(out))
        out = self.drop_out(out)
        out = self.relu(self.fc2(out))
        out = self.sigmoid(self.fc3(out))

        return out

I am unable to understand how will I use those extracted weights in CNN?