Using OpenAI image models to extract encondings

I am using code that can be found in this link that loads an image model and extracts encodings to perform some linear probing of my model. It makes use of cifar10 and "openai/imagegpt-small". The code I am using is the following:

    train_ds, test_ds = load_dataset('cifar10', split=['train[:10]', 'test[:10]'])
    # split up training into training + validation
    splits = train_ds.train_test_split(test_size=0.1)
    train_ds = splits['train']
    val_ds = splits['test']

    dataset = load_dataset('cifar10')
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

    feature_extractor = ImageGPTFeatureExtractor.from_pretrained("openai/imagegpt-small")
    model = ImageGPTModel.from_pretrained("openai/imagegpt-small")
    model.to(device)

    url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
    image = Image.open(requests.get(url, stream=True).raw)

    encoding = feature_extractor(image, return_tensors="pt")
    pixel_values = encoding.pixel_values.to(device)

I am facing a problem in the last line of my code, where the attribute pixel_values is not recognized and I am getting an error: raise AttributeError.

I am firstly, trying to understand what this pixel_values does in general and how to solve this issue.

Can you check if you are getting the encodings from calling feature_extractor. It could be the case that the method returns None and the pixel_values attribute is not found.