code: def log_download_attempts(
      urls,
      *,
      dataset_module,
  ):
      def maybe_add_mock(*, module, name, stack, lst=None):
          patcher = unittest.mock.patch(
              f"torchvision.datasets.{module}.{name}"
          )
  
          try:
              mock = stack.enter_context(patcher)
          except AttributeError:
              return
  
          if lst is not None:
              lst.append(mock)
  
      with contextlib.ExitStack() as stack:
          download_url_mocks = []
          download_file_from_google_drive_mocks = []
          for module in [dataset_module, "utils"]:
              maybe_add_mock(
                  module=module,
                  name="download_url",
                  stack=stack,
                  lst=download_url_mocks,
              )
              maybe_add_mock(
                  module=module,
                  name="download_file_from_google_drive",
                  stack=stack,
                  lst=download_file_from_google_drive_mocks,
              )
              maybe_add_mock(
                  module=module, name="extract_archive", stack=stack
              )
  
          try:
              yield
          finally:
              for download_url_mock in download_url_mocks:
                  for args, kwargs in download_url_mock.call_args_list:
                      urls.append(args[0] if args else kwargs["url"])
  
              for (
                  download_file_from_google_drive_mock
              ) in download_file_from_google_drive_mocks:
                  for (
                      args,
                      kwargs,
                  ) in (
                      download_file_from_google_drive_mock.call_args_list
                  ):
                      file_id = args[0] if args else kwargs["file_id"]
                      urls.append(
                          f"https://drive.google.com/file/d/{file_id}"
                      )
  
imports: import contextlib
  import itertools
  import tempfile
  import time
  import traceback
  import unittest.mock
  import warnings
  from datetime import datetime
  from distutils import dir_util
  from os import path
  from urllib.error import HTTPError, URLError
  from urllib.parse import urlparse
  from urllib.request import Request, urlopen
  import pytest
  from torchvision import datasets
  from torchvision.datasets.utils import _get_redirect_url, USER_AGENT
label_desc: Use image node_id 3 for calling a global function with example usage: log_download_attempts(urls) without return types