Is this copied, GEE specific? Can we inherit large parts from discrete_margins?