class_docstr: Singleton (use `get_extractor()` module fct) to extract archives.
docstr: Returns `to_path` once resource has been extracted there.
code: def _extract(
      self,
      from_path: epath.PathLike,
      method,
      to_path: epath.PathLike,
  ) -> epath.Path:
      """Returns `to_path` once resource has been extracted there."""
      to_path_tmp = "%s%s_%s" % (
          to_path,
          constants.INCOMPLETE_SUFFIX,
          uuid.uuid4().hex,
      )
      max_length_dst_path = 0
      futures = []
      if self._pbar_path is None:
          raise ValueError("'_pbar_path' is not initialized")
      try:
          for path, handle in iter_archive(from_path, method):
              path = tf.compat.as_text(path)
              dst_path = (
                  path
                  and os.path.join(to_path_tmp, path)
                  or to_path_tmp
              )
              max_length_dst_path = max(
                  max_length_dst_path, len(dst_path)
              )
              file_utils.makedirs_cached(os.path.dirname(dst_path))
              future = self._executor.submit(
                  _copy, handle.read(), dst_path
              )
              futures.append(future)
              self._pbar_path.update_total(1)
  
          # Wait until all copies have completed.
          for future in concurrent.futures.as_completed(futures):
              future.result()
              self._pbar_path.update(1)
      except BaseException as err:
          msg = (
              f"Error while extracting {from_path} to {to_path}: {err}"
          )
          # Check if running on windows
          if os.name == "nt" and max_length_dst_path > 250:
              msg += (
                  "\nOn windows, path lengths greater than 260 characters may result"
                  " in an error. See the doc to remove the limitation: "
                  "https://docs.python.org/3/using/windows.html#removing-the-max-path-limitation"
              )
          raise ExtractError(msg)
  
      # `tf.io.gfile.Rename(overwrite=True)` doesn't work for non empty
      # directories, so delete destination first, if it already exists.
      to_path = epath.Path(to_path)
      if to_path.exists():
          # `rename` is atomic, but not `rmtree`.
          # When 2 builder scripts (for each config) extract the same file, one can
          # `rename` while the other is still running `rmtree`, leading to corrupted
          # archive dir.
          path_to_delete = epath.Path(to_path_tmp + ".todelete")
          to_path.rename(path_to_delete)
          path_to_delete.rmtree()
      epath.Path(to_path_tmp).rename(to_path)
      return to_path
  
imports: import bz2
  import concurrent.futures
  import contextlib
  import gzip
  import multiprocessing
  import os
  import tarfile
  import typing
  from typing import Iterator, Tuple, Union
  import uuid
  import zipfile
  from absl import logging
  from etils import epath
  import promise
  from tensorflow_datasets.core import constants
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.download import resource
  from tensorflow_datasets.core.utils import file_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 4 for calling the _Extractor obj's underlying member method code with example usage: obj._extract(from_path, method, to_path) and returns: to_path