def _maybe_schedule_state_averaging(self) -> None:
    'If next epoch is coming soon, schedule the next state averaging at estimated parameter averaging start'
    next_epoch = max((self.local_epoch + 1), self.tracker.global_epoch)
    if ((next_epoch % self.average_state_every) != 0):
        return
    if self.state_averager.averaging_in_progress:
        return
    if (self.delay_before_state_averaging.num_updates == 0):
        return
    estimated_time = self.tracker.estimated_next_update_time
    estimated_time += self.delay_before_state_averaging.ema_seconds_per_sample
    estimated_time += self.state_averager.delay_before_averaging.ema_seconds_per_sample
    eta_seconds_to_averaging = (estimated_time - get_dht_time())
    if (eta_seconds_to_averaging <= self.matchmaking_time):
        if ((self.scheduled_state is None) or self.scheduled_state.triggered or self.scheduled_state.done()):
            min_matchmaking_time = self.state_averager.matchmaking_kwargs['min_matchmaking_time']
            actual_seconds = max(eta_seconds_to_averaging, min_matchmaking_time)
            logger.log(self.status_loglevel, f'Pre-scheduling state averaging round in {actual_seconds:.2f} sec')
            self.scheduled_state = self.state_averager.schedule_step(gather=next_epoch, timeout=self.averaging_timeout)
If next epoch is coming soon, schedule the next state averaging at estimated parameter averaging start
def _maybe_schedule_state_averaging(self) -> None:
    
    next_epoch = max((self.local_epoch + 1), self.tracker.global_epoch)
    if ((next_epoch % self.average_state_every) != 0):
        return
    if self.state_averager.averaging_in_progress:
        return
    if (self.delay_before_state_averaging.num_updates == 0):
        return
    estimated_time = self.tracker.estimated_next_update_time
    estimated_time += self.delay_before_state_averaging.ema_seconds_per_sample
    estimated_time += self.state_averager.delay_before_averaging.ema_seconds_per_sample
    eta_seconds_to_averaging = (estimated_time - get_dht_time())
    if (eta_seconds_to_averaging <= self.matchmaking_time):
        if ((self.scheduled_state is None) or self.scheduled_state.triggered or self.scheduled_state.done()):
            min_matchmaking_time = self.state_averager.matchmaking_kwargs['min_matchmaking_time']
            actual_seconds = max(eta_seconds_to_averaging, min_matchmaking_time)
            logger.log(self.status_loglevel, f'Pre-scheduling state averaging round in {actual_seconds:.2f} sec')
            self.scheduled_state = self.state_averager.schedule_step(gather=next_epoch, timeout=self.averaging_timeout)