It looks like cfg["training"]["train_iters"] corresponds to the epochs, so just move the increment of i before the for loop:
while i <= cfg["training"]["train_iters"] and flag:
        i += 1
        for idx,(images, labels) in enumerate(tbar):
            print('epoch {}--------------------------'.format(i))
            print('iter {}---------------------------'.format(idx))