code: def _copytree(
      entries: List,
      src: str,
      dst: str,
      selector: Optional[Callable[[str], bool]],
      src_root: str,
  ) -> str:
      errors = []
      have_copied = False
      for srcobj in entries:
          srcname = os.path.join(src, srcobj.name)
          dstname = os.path.join(dst, srcobj.name)
          src_relpath = os.path.relpath(srcname, src_root)
          try:
              if srcobj.is_dir():
                  # Directories are created here only if they are specified
                  # in the selector. If a directory is not specified in
                  # the selector, and it is required by any nested files,
                  # the directory will be created then.
                  if selector is None or selector(src_relpath + "/"):
                      os.makedirs(dstname, exist_ok=True)
                      have_copied = True
                  copytree(
                      srcobj,
                      dstname,
                      selector,
                      src_root,
                  )
              else:
                  # If selector is None all files are copied; if selector is not None
                  # then files are copied according to the selector. Before files
                  # are copied all top directory structure is created. This ensures
                  # that copied dirs are not dangling.
                  if selector is None or selector(src_relpath):
                      have_copied = True
                      os.makedirs(dst, exist_ok=True)
                      shutil.copy2(srcobj, dstname)
          # catch the Error from the recursive copytree so that we can
          # continue with other files
          except shutil.Error as err:
              errors.extend(err.args[0])
          except OSError as why:
              errors.append((srcname, dstname, str(why)))
      if have_copied:
          try:
              shutil.copystat(src, dst)
          except OSError as why:
              # Copying file access times may fail on Windows
              if getattr(why, "winerror", None) is None:
                  errors.append((src, dst, str(why)))
      if errors:
          raise shutil.Error(errors)
      return dst
  
imports: import contextlib
  import glob
  import logging
  import os
  import pathlib
  import shutil
  from typing import Any, Callable, Dict, Iterator, List, Optional, Union
  from determined import errors, util
  from determined.common import check, storage
label_desc: Use image node_id 1 for calling a global function with example usage: _copytree(entries, src, dst, selector, src_root) and returns: dst