you can always dynamically concatenate the arrays of sizes V_global, V_instance_specific to get V_global + V_instance_specific sized array and use F.log_softmax() + NLLLoss() [https://pytorch.org/docs/stable/nn.html#torch.nn.functional.softmax 8] dynamically.