code: def download_youtube_videos(
      urls,
      download_dir=None,
      video_paths=None,
      clip_segments=None,
      ext=".mp4",
      only_progressive=True,
      resolution="highest",
      max_videos=None,
      num_workers=None,
      skip_failures=True,
      quiet=False,
  ):
      """Downloads a list of YouTube videos.
  
      The ``urls`` argument accepts a list of YouTube "watch" URLs::
  
          urls = [
              "https://www.youtube.com/watch?v=-0URMJE8_PB",
              ...,
          ]
  
      Use either the ``download_dir`` or ``video_paths`` argument to specify
      where to download each video.
  
      You can use the optional ``clip_segments`` argument to specify a specific
      segment, in seconds, of each video to download::
  
          clip_segments = [
              (10, 25),
              (11.1, 20.2),
              None,               # entire video
              (None, 8.0),        # through beginning of video
              (8.0, None),        # through end of video
              ...
          ]
  
      You can also use the optional ``ext`` and ``resolution`` arguments to
      specify a deisred video codec and resolution to download, if possible.
  
      YouTube videos are regularly taken down. Therefore, this method provides an
      optional ``max_videos`` argument that you can use in conjunction with
      ``skip_failures=True`` and a large list of possibly non-existent videos in
      ``urls`` in cases where you need a certain number of videos to be
      successfully downloaded but are willing to tolerate failures.
  
      Args:
          urls: a list of YouTube URLs to download
          download_dir (None): a directory in which to store the downloaded
              videos
          video_paths (None): a list of paths to which to download the videos.
              When downloading entire videos, a stream matching the video format
              implied by each file's extension is downloaded, if available, or
              else the extension of the video path is **changed** to match the
              available stream's format
          clip_segments (None): a list of ``(first, last)`` tuples defining a
              specific segment of each video to download
          ext (".mp4"): a video format to download for each video, if possible.
              Only applicable when a ``download_dir`` is used. This format will
              be respected if such a stream exists, otherwise the format of the
              best available stream is used. Set this value to ``None`` if you
              want to download the stream with the best match for ``resolution``
              and ``progressive`` regardless of format
          only_progressive (True): whether to only download progressive streams,
              if possible. Progressive streams contain both audio and video
              tracks and are typically only available at <= 720p resolution
          resolution ("highest"): a desired stream resolution to download. This
              filter is applied after respecting the desired video format and
              ``only_progressive`` restriction, if applicable. The supported
              values are:
  
              -   ``"highest"`` (default): download the highest resolution stream
              -   ``"lowest"``:  download the lowest resolution stream
              -   A target resolution like ``"1080p"``. In this case, the stream
                  whose resolution is closest to this target value is downloaded
          max_videos (None): the maximum number of videos to successfully
              download. By default, all videos are downloaded
          num_workers (None): a suggested number of threads/processes to use when
              downloading videos
          skip_failures (True): whether to gracefully continue without raising
              an error if a video cannot be downloaded
          quiet (False): whether to suppress logging, except for a progress bar
  
      Returns:
          a tuple of
  
          -   **downloaded**: a dict mapping integer indexes into ``urls`` to
              paths of successfully downloaded videos
          -   **errors**: a dict mapping integer indexes into ``urls`` to error
              messages for videos that were attempted to be downloaded, but
              failed
      """
      use_threads = clip_segments is None
      num_workers = _parse_num_workers(
          num_workers, use_threads=use_threads
      )
  
      if max_videos is None:
          max_videos = len(urls)
  
      with etau.TempDir() as tmp_dir:
          tasks = _build_tasks_list(
              urls,
              download_dir,
              video_paths,
              clip_segments,
              tmp_dir,
              ext,
              only_progressive,
              resolution,
          )
  
          if num_workers <= 1:
              downloaded, errors = _download(
                  tasks, max_videos, skip_failures, quiet
              )
          else:
              downloaded, errors = _download_multi(
                  tasks,
                  max_videos,
                  skip_failures,
                  quiet,
                  num_workers,
                  use_threads,
              )
  
      return downloaded, errors
  
imports: import importlib
  import itertools
  import logging
  import multiprocessing.dummy
  import os
  import numpy
  import eta.core.utils
  import eta.core.video
  import fiftyone.core.utils
label_desc: Use image node_id 2 for calling a global function with example usage: download_youtube_videos(urls, download_dir, video_paths, clip_segments, ext, only_progressive, resolution, max_videos, num_workers, skip_failures, quiet) and returns: downloaded,  errors