def flip(image, random_flip): if random_flip and np.random.choice([True, False]): image = np.fliplr(image) return image