public function filter_out_invalid_samples(&$sampleids, \core_analytics\analysable $analysable, $fortraining = true) {
        foreach ($sampleids as $sampleid => $unusedsampleid) {
            if (!$this->is_valid_sample($sampleid, $analysable, $fortraining)) {
                // Skip it and remove the sample from the list of calculated samples.
                unset($sampleids[$sampleid]);
            }
        }
    }