def METHOD_NAME(sample, mode, color_jitter, rotate, crop_size, resize_size):
    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 = random_crop(img, crop_size)
    else:
        img = resize_short(img, target_size=resize_size)
        img = crop_image(img, target_size=crop_size, 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.array(img).astype('float32').transpose((2, 0, 1)) / 255
    img -= img_mean
    img /= img_std
    if mode == 'train' or mode == 'val':
        return img, sample[1]
    elif mode == 'test':
        return [img]