def auto_adapt_batch(train_size, val_size, batch_count_multiple=1, max_size=256):
    """
    returns a suitable batch size according to train and val dataset size,
    say max_size = 128, and val_size is smaller than train_size,
        if val_size < 128, the batch_size1 to be returned is val_size
        if 128 < val_size <= 256, the batch size is 1/2 of val_size, at most 1 validation sample cannot be used
        if 256 < val_size <= 384, the batch size is 1/3 of val_size, at most 2 validation samples cannot be used
        ...
    :param train_size: the number of training samples in the training set
    :param val_size: the number of validation samples in the validation set
    :param max_size: the maximum batch_size1 that is allowed to be returned
    :param batch_count_multiple: force the batch count to be a multiple of this number, default = 1
    :return: a suitable batch_size1 for the input
    """
    print('Auto adapting batch size...')
    numerator = min(train_size, val_size)
    denominator = 0
    while True:
        denominator += batch_count_multiple
        batch_size = numerator // denominator
        if batch_size <= max_size: return batch_size