modified vector gathering
some fixes
avoid additional duplication of samples_
template version of gather_region_optimization_vector
preps for training both sides