First of all:



 kl_divergence:

clf_outputs["y1"] = self.fc0(f) 
clf_outputs=["y2"] = self.fc1(f)



you don’t need this part as



 kl_divergence:

for i in range(self.num_fcs): 
    clf_outputs["fc%d" %i] = getattr(self, "fc%d" %i)(f)



also stores the same results in clf_outputs["fc0"] and clf_outputs["fc1"] instead of clf_outputs["y1"] and clf_outputs["y2"]
Second: thats not what I meant. you simply sould use your forward function like
def forward(self,x):
        x = self.base(x)
        x = F.avg_pool2d(x,x.size()[2:])
        f = x.view(x.size(0),-1)
        clf_outputs = {}
        for i in range(self.num_fcs):
            clf_outputs["fc%d" %i] = getattr(self, "fc%d" %i)(f)

        if self.loss == {'xent'}:
            return clf_outputs
        elif self.loss == {'xent','htri'}:
            return clf_outputs,f
        elif self.loss == {'cent'}:
            return clf_outputs,f
        else:
            raise KeyError("Unsupported loss:{}".format(self.loss))


after you created a model instance with model = ResNet50(10) you cann do some predictions with clf_outputs, f = model(data_tensor) and later on calculate a loss for each of the values in clf_outputs:
In the following snippet I assume you have a list of targets (one per fc layer)!
model = ResNet(10, num_fcs=2)
optim = SGD(model.parameters())
clf_outputs, f = model(data_tensor)

# for simplicity I'm using MSE-Loss but you could simply use any other loss function as well
loss_fn = MSELoss()
loss_value = 0
for k, v in clf_outputs.items():
    _curr_loss = loss_fn(v, target_list[int(k.replace("fc", ""))])
    loss_val = loss_val + _curr_loss

optim.zero_grad()
loss_value.backward()
optim.step()