def METHOD_NAME(sample, mode, color_jitter, rotate):
    img_path = sample[0]
    try:
        img = Image.open(img_path)
    except:
        print(img_path, "not exists!")
        return None
    if mode == 'train':
        if rotate: img = rotate_image(img)
        img = crop_image(img, target_size=DATA_DIM, center=False)
    else:
        img = crop_image(img, target_size=DATA_DIM, center=True)
    if mode == 'train':
        if color_jitter:
            img = distort_color(img)
        if np.random.randint(0, 2) == 1:
            img = img.transpose(Image.FLIP_LEFT_RIGHT)
    if img.mode != 'RGB':
        img = img.convert('RGB')
    img = np.float32(img)
    img = img / 255.0
    img -= 0.5
    img *= 2.0
    if mode == 'train' or mode == 'val':
        return img, sample[1]
    elif mode == 'test':
        return [img]