Is there a generic way of going by to implement a custom loss function based on a problem statement? For instance, if redistricting of the districts in a state on the US and