How to use sliced model parameters as Variable?

the model below: how can I use the detached_w(1000*512) parameter as a Variable to be involved in
the computational graph? Anything worth paying attention to?

class CNN(nn.Module):
    def __init__(self):
        super(CNN, self).__init__()
        self.pretrained = models.resnet18(pretrained=True)
        self.modules = list(self.pretrained.children())[:-2]
        self.resnet = nn.Sequential(*self.modules)
        self.layer1 =nn.AvgPool2d(7)
        self.layer2 = self.pretrained.fc
    def forward(self,input):
        o0 = self.resnet(input)
        o1 = self.layer1(o0)
        o2 = o1.squeeze(2)
        o2 = o2.squeeze(2)
        o3 = self.layer2(o2)
        for ii,param in enumerate(self.pretrained.fc.parameters()):
            if ii==0:
                detached_w = param.detach()
        return o3,detached_w

How do you want to use it? You could create a new Variable with requires_grad=True and register it as a parameter with your module: .

how to slicing a Variable “x”, and pass the sliced tensor to another model B, while the Variable “x” is actually a parameter of a fully connected layer (like layer2 in my description above) in model A?