class_docstr: Reading instruction for a dataset.
  
  Examples::
  
    # The following lines are equivalent:
    ds = datasets.load_dataset('mnist', split='test[:33%]')
    ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction.from_spec('test[:33%]'))
    ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction('test', to=33, unit='%'))
    ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction(
        'test', from_=0, to=33, unit='%'))
  
    # The following lines are equivalent:
    ds = datasets.load_dataset('mnist', split='test[:33%]+train[1:-1]')
    ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction.from_spec(
        'test[:33%]+train[1:-1]'))
    ds = datasets.load_dataset('mnist', split=(
        datasets.ReadInstruction('test', to=33, unit='%') +
        datasets.ReadInstruction('train', from_=1, to=-1, unit='abs')))
  
    # The following lines are equivalent:
    ds = datasets.load_dataset('mnist', split='test[:33%](pct1_dropremainder)')
    ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction.from_spec(
        'test[:33%](pct1_dropremainder)'))
    ds = datasets.load_dataset('mnist', split=datasets.ReadInstruction(
        'test', from_=0, to=33, unit='%', rounding="pct1_dropremainder"))
  
    # 10-fold validation:
    tests = datasets.load_dataset(
        'mnist',
        [datasets.ReadInstruction('train', from_=k, to=k+10, unit='%')
        for k in range(0, 100, 10)])
    trains = datasets.load_dataset(
        'mnist',
        [datasets.ReadInstruction('train', to=k, unit='%') + datasets.ReadInstruction('train', from_=k+10, unit='%')
        for k in range(0, 100, 10)])
class_docstr_tok: ["Reading","instruction","for","a","dataset",".","Examples",":",":","#","The","following","lines","are","equivalent",":","ds","=","datasets.load_dataset","(","'mnist","'",",","split='test","[",":33","%","]","'",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=datasets.ReadInstruction.from_spec","(","'test","[",":33","%","]","'",")",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=datasets.ReadInstruction","(","'test","'",",","to=33",",","unit=","'","%","'",")",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=datasets.ReadInstruction","(","'test","'",",","from_=0",",","to=33",",","unit=","'","%","'",")",")","#","The","following","lines","are","equivalent",":","ds","=","datasets.load_dataset","(","'mnist","'",",","split='test","[",":33","%","]","+train","[","1",":","-1","]","'",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=datasets.ReadInstruction.from_spec","(","'test","[",":33","%","]","+train","[","1",":","-1","]","'",")",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=","(","datasets.ReadInstruction","(","'test","'",",","to=33",",","unit=","'","%","'",")","+","datasets.ReadInstruction","(","'train","'",",","from_=1",",","to=-1",",","unit='abs","'",")",")",")","#","The","following","lines","are","equivalent",":","ds","=","datasets.load_dataset","(","'mnist","'",",","split='test","[",":33","%","]","(","pct1_dropremainder",")","'",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=datasets.ReadInstruction.from_spec","(","'test","[",":33","%","]","(","pct1_dropremainder",")","'",")",")","ds","=","datasets.load_dataset","(","'mnist","'",",","split=datasets.ReadInstruction","(","'test","'",",","from_=0",",","to=33",",","unit=","'","%","'",",","rounding=","''","pct1_dropremainder","''",")",")","#","10-fold","validation",":","tests","=","datasets.load_dataset","(","'mnist","'",",","[","datasets.ReadInstruction","(","'train","'",",","from_=k",",","to=k+10",",","unit=","'","%","'",")","for","k","in","range","(","0",",","100",",","10",")","]",")","trains","=","datasets.load_dataset","(","'mnist","'",",","[","datasets.ReadInstruction","(","'train","'",",","to=k",",","unit=","'","%","'",")","+","datasets.ReadInstruction","(","'train","'",",","from_=k+10",",","unit=","'","%","'",")","for","k","in","range","(","0",",","100",",","10",")","]",")"]
docstr: Creates a `ReadInstruction` instance out of a string spec.
  
  Args:
      spec (`str`):
          Split(s) + optional slice(s) to read + optional rounding
          if percents are used as the slicing unit. A slice can be specified,
          using absolute numbers (`int`) or percentages (`int`).
  
  Examples:
  
      ```
      test: test split.
      test + validation: test split + validation split.
      test[10:]: test split, minus its first 10 records.
      test[:10%]: first 10% records of test split.
      test[:20%](pct1_dropremainder): first 10% records, rounded with the pct1_dropremainder rounding.
      test[:-5%]+train[40%:60%]: first 95% of test + middle 20% of train.
      ```
  
  Returns:
      ReadInstruction instance.
code: def from_spec(cls, spec):
      """Creates a `ReadInstruction` instance out of a string spec.
  
      Args:
          spec (`str`):
              Split(s) + optional slice(s) to read + optional rounding
              if percents are used as the slicing unit. A slice can be specified,
              using absolute numbers (`int`) or percentages (`int`).
  
      Examples:
  
          ```
          test: test split.
          test + validation: test split + validation split.
          test[10:]: test split, minus its first 10 records.
          test[:10%]: first 10% records of test split.
          test[:20%](pct1_dropremainder): first 10% records, rounded with the pct1_dropremainder rounding.
          test[:-5%]+train[40%:60%]: first 95% of test + middle 20% of train.
          ```
  
      Returns:
          ReadInstruction instance.
      """
      spec = str(
          spec
      )  # Need to convert to str in case of NamedSplit instance.
      subs = _ADDITION_SEP_RE.split(spec)
      if not subs:
          raise ValueError(
              f"No instructions could be built out of {spec}"
          )
      instruction = _str_to_read_instruction(subs[0])
      return sum(
          (_str_to_read_instruction(sub) for sub in subs[1:]),
          instruction,
      )
  
imports: import copy
  import math
  import os
  import re
  import shutil
  from dataclasses import dataclass
  from pathlib import Path
  from typing import TYPE_CHECKING, List, Optional, Union
  import pyarrow
  import pyarrow.parquet
  from .download.download_config import DownloadConfig
  from .naming import _split_re, filenames_for_dataset_split
  from .table import InMemoryTable, MemoryMappedTable, Table, concat_tables
  from .utils import logging
  from .utils.file_utils import cached_path
label_desc: Use image node_id 4 for calling the ReadInstruction obj's underlying member method code with example usage: obj.from_spec(cls, spec) and returns: sum