'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()
                s = ('Epoch[%d]    Batch    [%d] DCTB Speed:    %.2f    samples/sec DCTB Train-' % (param.epoch, count, speed))
                for (n, v) in zip(name, value):
                    s += ('%s=%f, DCTB ' % (n, v))
                logging.info(s)
            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()
