code: def test_image_webdataset(image_wds_file):
      import PIL.Image
  
      data_files = {"train": [image_wds_file]}
      webdataset = WebDataset(data_files=data_files)
      split_generators = webdataset._split_generators(DownloadManager())
      assert webdataset.info.features == Features(
          {
              "__key__": Value("string"),
              "__url__": Value("string"),
              "json": {"caption": Value("string")},
              "jpg": Image(),
          }
      )
      assert len(split_generators) == 1
      split_generator = split_generators[0]
      assert split_generator.name == "train"
      generator = webdataset._generate_examples(
          **split_generator.gen_kwargs
      )
      _, examples = zip(*generator)
      assert len(examples) == 3
      assert isinstance(examples[0]["json"], dict)
      assert isinstance(examples[0]["json"]["caption"], str)
      assert isinstance(
          examples[0]["jpg"], dict
      )  # keep encoded to avoid unecessary copies
      encoded = webdataset.info.features.encode_example(examples[0])
      decoded = webdataset.info.features.decode_example(encoded)
      assert isinstance(decoded["json"], dict)
      assert isinstance(decoded["json"]["caption"], str)
      assert isinstance(decoded["jpg"], PIL.Image.Image)
  
file_path: datasets/tests/packaged_modules/test_webdataset.py
imports: import json
  import tarfile
  import numpy
  import pytest
  from datasets import Audio, DownloadManager, Features, Image, Value
  from datasets.packaged_modules.webdataset.webdataset import WebDataset
  from ..utils import require_pil, require_sndfile
label_desc: Use image node_id 4 for calling a global function with example usage: test_image_webdataset(image_wds_file) without return types