code: def __init__(
      self,
      root: str,
      name: Optional[str] = None,
      split: str = "train",
      is_training: bool = False,
      num_samples: Optional[int] = None,
      batch_size: int = 1,
      repeats: int = 0,
      seed: int = 42,
      class_map: Optional[dict] = None,
      input_key: str = "jpg;png;webp",
      input_img_mode: str = "RGB",
      target_key: str = "cls",
      target_img_mode: str = "",
      filename_key: str = "filename",
      sample_shuffle_size: Optional[int] = None,
      smaple_initial_size: Optional[int] = None,
  ):
      super().__init__()
      if wds is None:
          raise RuntimeError(
              "Please install webdataset 0.2.x package `pip install git+https://github.com/webdataset/webdataset`."
          )
      self.root = root
      self.is_training = is_training
      self.batch_size = batch_size
      self.repeats = repeats
      self.common_seed = seed  # a seed that's fixed across all worker / distributed instances
      self.shard_shuffle_size = 500
      self.sample_shuffle_size = (
          sample_shuffle_size or SAMPLE_SHUFFLE_SIZE
      )
      self.sample_initial_size = (
          smaple_initial_size or SAMPLE_INITIAL_SIZE
      )
  
      self.input_key = input_key
      self.input_img_mode = input_img_mode
      self.target_key = target_key
      self.filename_key = filename_key
      self.key_ext = ".JPEG"  # extension to add to key for original filenames (DS specific, default ImageNet)
  
      self.info = _load_info(self.root)
      self.split_info = _parse_split_info(split, self.info)
      if num_samples is not None:
          self.num_samples = num_samples
      else:
          self.num_samples = self.split_info.num_samples
      if not self.num_samples:
          raise RuntimeError(
              f"Invalid split definition, num_samples not specified."
          )
      self.remap_class = False
      if class_map:
          self.class_to_idx = load_class_map(class_map)
          self.remap_class = True
      else:
          self.class_to_idx = {}
  
      # Distributed world state
      self.dist_rank = 0
      self.dist_num_replicas = 1
      if (
          dist.is_available()
          and dist.is_initialized()
          and dist.get_world_size() > 1
      ):
          self.dist_rank = dist.get_rank()
          self.dist_num_replicas = dist.get_world_size()
  
      # Attributes that are updated in _lazy_init
      self.worker_info = None
      self.worker_id = 0
      self.worker_seed = seed  # seed unique to each worker instance
      self.num_workers = 1
      self.global_worker_id = 0
      self.global_num_workers = 1
      self.init_count = 0
      self.epoch_count = SharedCount()
  
      # DataPipeline is lazy init, the majority of WDS DataPipeline could be init here, BUT, shuffle seed
      # is not handled in manner where it can be deterministic for each worker AND initialized up front
      self.ds = None
  
imports: import io
  import json
  import logging
  import math
  import os
  import random
  import sys
  from dataclasses import dataclass
  from functools import partial
  from itertools import islice
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  import torch.distributed
  import yaml
  from PIL import Image
  from torch.utils.data import Dataset, IterableDataset, get_worker_info
  from .class_map import load_class_map
  from .reader import Reader
  from .shared_count import SharedCount
label_desc: Use image node_id 1 to create a new ReaderWds object from inherited base classes: Reader with example: obj = ReaderWds(root, name, split, is_training, num_samples, batch_size, repeats, seed, class_map, input_key, input_img_mode, target_key, target_img_mode, filename_key, sample_shuffle_size, smaple_initial_size)