def METHOD_NAME(self, x, weight_mat=None):
    out = self.gru_features(x)
    fea = out[0]
    if self.use_bottleneck:
        fea_bottleneck = self.bottleneck(fea[:, -1, :])
        fc_out = self.fc(fea_bottleneck).squeeze()
    else:
        fc_out = self.fc_out(fea[:, -1, :]).squeeze()
    out_list_all = out[1]
    out_list_s, out_list_t = self.get_features(out_list_all)
    loss_transfer = torch.zeros((1,)).cuda()
    if weight_mat is None:
        weight = (1.0 / self.len_seq *
                  torch.ones(self.num_layers, self.len_seq)).cuda()
    else:
        weight = weight_mat
    dist_mat = torch.zeros(self.num_layers, self.len_seq).cuda()
    for i in range(len(out_list_s)):
        criterion_transder = TransferLoss(
            loss_type=self.trans_loss, input_dim=out_list_s[i].shape[2])
        for j in range(self.len_seq):
            loss_trans = criterion_transder.compute(
                out_list_s[i][:, j, :], out_list_t[i][:, j, :])
            loss_transfer = loss_transfer + weight[i, j] * loss_trans
            dist_mat[i, j] = loss_trans
    return fc_out, loss_transfer, dist_mat, weight