The gd just means groupby(test, "subject"), i.e. the grouped data frame.
I think you are on the right track. I would just put the labels in your original combine call, i.e.
combine(groupby(test, "subject"), [] => (()-> labels) => "label", getproduct()...)