code: def test_dataset_cast_to_image_features(shared_datadir, build_data):
      import PIL.Image
  
      image_path = str(shared_datadir / "test_image_rgb.jpg")
      data = build_data(image_path)
      dset = Dataset.from_dict(data)
      item = dset.cast(Features({"image": Image()}))[0]
      assert item.keys() == {"image"}
      assert isinstance(item["image"], PIL.Image.Image)
      item = dset.cast_column("image", Image())[0]
      assert item.keys() == {"image"}
      assert isinstance(item["image"], PIL.Image.Image)
  
imports: import os
  import tarfile
  import warnings
  import numpy
  import pandas
  import pyarrow
  import pytest
  from datasets import Dataset, Features, Image, Sequence, Value, concatenate_datasets, load_dataset
  from datasets.features.image import encode_np_array, image_to_bytes
  from ..utils import require_pil
label_desc: Use image node_id 12 for calling a global function with example usage: test_dataset_cast_to_image_features(shared_datadir, build_data) without return types