code: def download(
      fs: "FileSystem",
      fs_path: str,
      to: str,
      jobs: Optional[int] = None,
  ) -> int:
      from dvc.scm import lfs_prefetch
  
      from .callbacks import TqdmCallback
  
      with TqdmCallback(
          desc=f"Downloading {fs.name(fs_path)}",
          unit="files",
      ) as cb:
          # NOTE: We use dvc-objects generic.copy over fs.get since it makes file
          # download atomic and avoids fsspec glob/regex path expansion.
          if fs.isdir(fs_path):
              from_infos = [
                  path
                  for path in fs.find(fs_path)
                  if not path.endswith(fs.flavour.sep)
              ]
              if not from_infos:
                  localfs.makedirs(to, exist_ok=True)
                  return 0
              to_infos = [
                  localfs.join(to, *fs.relparts(info, fs_path))
                  for info in from_infos
              ]
          else:
              from_infos = [fs_path]
              to_infos = [to]
  
          if isinstance(fs, DVCFileSystem):
              lfs_prefetch(fs, from_infos)
          cb.set_size(len(from_infos))
          jobs = jobs or fs.jobs
          generic.copy(
              fs,
              from_infos,
              localfs,
              to_infos,
              callback=cb,
              batch_size=jobs,
          )
          return len(to_infos)
  
file_path: dvc/dvc/fs/__init__.py
imports: from typing import Optional
  from urllib.parse import urlparse
  from dvc_http import HTTPFileSystem, HTTPSFileSystem
  from dvc.config import ConfigError
  from dvc.config_schema import SCHEMA, Invalid
  from dvc_objects.fs import LocalFileSystem, MemoryFileSystem, Schemes, generic, get_fs_cls, known_implementations, localfs, registry, system, utils
  from dvc_objects.fs.base import AnyFSPath, FileSystem
  from dvc_objects.fs.errors import AuthError, ConfigError, RemoteMissingDepsError
  from .callbacks import Callback
  from .data import DataFileSystem
  from .dvc import DVCFileSystem
  from .git import GitFileSystem
label_desc: Use image node_id 1 for calling a global function with example usage: download(fs, fs_path, to, jobs) and returns: len, int