'Called when minibatch is about to end
Arguments:
callback_data (HDF5 dataset): shared data between callbacks
model (Model): model object
epoch (int): index of current epoch
minibatch (int): index of minibatch that is ending'

def on_minibatch_end(self, callback_data, model, epoch, minibatch):

    now = default_timer()
    mb_complete = (minibatch + 1)
    if (((now - self.last_update) > self.update_thresh_s) or (mb_complete == self.nbatches)):
        self.last_update = now
        mbstart = (callback_data['time_markers/minibatch'][(epoch - 1)] if (epoch > 0) else 0)
        if ('cost/train' in callback_data):
            train_cost = callback_data['cost/train'][(mbstart + minibatch)]
        elif ('multicost/train' in callback_data):
            train_cost = callback_data['multicost/train'][(mbstart + minibatch)]
        else:
            train_cost = 'na'
        progress_string = get_progress_string('Train', epoch, mb_complete, self.nbatches, train_cost, (now - self.start_epoch))
        sys.stdout.write((('\r' + ('    ' * self._last_strlen)) + '\r'))
        if PY3:
            sys.stdout.write(progress_string)
        else:
            sys.stdout.write(progress_string.encode('utf-8'))
        self._last_strlen = len(progress_string)
        sys.stdout.flush()
