Loss Function for predicting an structured opject

Hi All,
I am trying to implement a encoder-decoder based model. But at the decoder step instead of just predicting one value, I need to generate couple of values so that they can be fields of an object. Generating each of these elements are important. First I am choosing the function, and arguments. and what I am generating is the output of the funtion over the arguments. I want to define a loss function that lead to choosing a correct function and correct arguments,. Is there a way I can do that easily?