code: def _do_download(task):
      (
          idx,
          url,
          download_dir,
          video_path,
          clip_segment,
          tmp_dir,
          ext,
          only_progressive,
          resolution,
      ) = task
  
      error = None
      warnings = []
  
      try:
          pytube_video = pytube.YouTube(url)
          _validate_video(pytube_video)
  
          if video_path is not None and ext is None:
              ext = os.path.splitext(video_path)[1]
  
          stream = _get_stream(
              pytube_video, ext, only_progressive, resolution
          )
  
          if video_path is None:
              filename = stream.default_filename
              if ext is not None:
                  filename = os.path.splitext(filename)[0] + ext
  
              video_path = os.path.join(download_dir, filename)
  
          root, ext = os.path.splitext(video_path)
          stream_ext = os.path.splitext(stream.default_filename)[1]
          if ext != stream_ext:
              warnings.append(
                  (
                      "Unable to find a '%s' stream for '%s'; downloading '%s' "
                      "instead"
                  )
                  % (ext, url, stream_ext)
              )
  
              video_path = root + stream_ext
  
          if only_progressive and not stream.is_progressive:
              warnings.append(
                  (
                      "Unable to find a progressive stream for '%s'; "
                      "downloading a non-progressive stream instead"
                  )
                  % url
              )
  
          if etau.is_numeric(resolution):
              target_res = "%dp" % resolution
              stream_res = stream.resolution
              if target_res != stream_res:
                  warnings.append(
                      (
                          "Unable to find a '%s' stream for '%s'; downloading a "
                          "'%s' stream instead"
                      )
                      % (target_res, url, stream_res)
                  )
  
          # Download to a temporary location first and then move to `video_path`
          # so that only successful downloads end up at their final destination
          tmp_path = os.path.join(tmp_dir, os.path.basename(video_path))
  
          if clip_segment is None:
              _download_video(stream, tmp_path)
          else:
              _download_clip(stream, clip_segment, tmp_path)
  
          etau.move_file(tmp_path, video_path)
      except Exception as e:
          video_path = None
          if isinstance(e, pytube.exceptions.PytubeError):
              error = type(e)
          else:
              error = str(e)
  
      return idx, url, video_path, error, warnings
  
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 7 for calling a global function with example usage: _do_download(task) and returns: idx,  url,  video_path,  error,  warnings