docstr: untar imagenet tar files into directories that indicate their label.
  
  returns [(filename, label), ...] for train or val set partitions
docstr_tok: ["untar","imagenet","tar","files","into","directories","that","indicate","their","label",".","returns","[","(","filename",",","label",")",",","...","]","for","train","or","val","set","partitions"]
code: def train_or_val_pairs(self, setn):
      """
      untar imagenet tar files into directories that indicate their label.
  
      returns [(filename, label), ...] for train or val set partitions
      """
      img_dir = os.path.join(self.out_dir, setn)
  
      neon_logger.display("Extracting %s files" % (setn))
      root_tf_path = self.tars[setn]
      if not os.path.exists(root_tf_path):
          raise IOError(
              (
                  "tar file {} not found. Ensure you have ImageNet downloaded"
              ).format(root_tf_path)
          )
  
      try:
          root_tf = tarfile.open(root_tf_path)
      except tarfile.ReadError as e:
          raise ValueError(
              "ReadError opening {}: {}".format(root_tf_path, e)
          )
  
      label_dict = self.extract_labels(setn)
      subpaths = root_tf.getmembers()
      arg_iterator = zip(
          repeat(self.target_size),
          repeat(root_tf_path),
          repeat(img_dir),
          repeat(setn),
          repeat(label_dict),
          subpaths,
      )
      pool = multiprocessing.Pool()
  
      pairs = []
      for pair_list in tqdm.tqdm(
          pool.imap_unordered(process_i1k_tar_subpath, arg_iterator),
          total=len(subpaths),
      ):
          pairs.extend(pair_list)
      pool.close()
      pool.join()
      root_tf.close()
  
      return pairs
  
imports: from builtins import str, zip
  from configargparse import ArgParser
  from itertools import repeat
  from neon import logger
  from neon.util.persist import ensure_dirs_exist
  from PIL import Image
  import logging
  import multiprocessing
  import numpy
  import os
  import re
  import shutil
  import tarfile
  import tqdm
  import zlib
label_desc: Use image node_id 4 for calling the IngestI1K obj's underlying member method code with example usage: obj.train_or_val_pairs(setn) and returns: pairs