'Called right before processing a batch.
# Arguments
batch: integer, index of batch within the current epoch.
logs: dictionary of logs.'

def on_batch_begin(self, batch, logs=None):

    logs = (logs or {})
    t_before_callbacks = time.time()
    for callback in self.callbacks:
        callback.on_batch_begin(batch, logs)
    self._delta_ts_batch_begin.append((time.time() - t_before_callbacks))
    delta_t_median = np.median(self._delta_ts_batch_begin)
    if ((self._delta_t_batch > 0.0) and (delta_t_median > (0.95 * self._delta_t_batch)) and (delta_t_median > 0.1)):
        warnings.warn(('Method    on_batch_begin()    is    slow    compared    to    the    batch    update    (%f).    Check    your    callbacks.' % delta_t_median))
    self._t_enter_batch = time.time()
