'Callback to Show speed.'

def __call__(self, param):

    count = param.nbatch
    if (self.last_count > count):
        self.init = False
    self.last_count = count
    if self.init:
        if ((count % self.frequent) == 0):
            speed = ((self.frequent * self.batch_size) / (time.time() - self.tic))
            if (param.eval_metric is not None):
                name_value = param.eval_metric.get_name_value()
                if self.auto_reset:
                    param.eval_metric.reset()
                msg = 'Epoch[%d]    Batch    [%d] DCTB Speed:    %.2f    samples/sec'
                msg += (' DCTB %s=%f' * len(name_value))
                logging.info(msg, param.epoch, count, speed, *sum(name_value, ()))
            else:
                logging.info('Iter[%d]    Batch    [%d] DCTB Speed:    %.2f    samples/sec', param.epoch, count, speed)
            self.tic = time.time()
    else:
        self.init = True
        self.tic = time.time()
