code: def disable_weight_loading(mocker):
      """When testing models, the two slowest operations are the downloading of the weights to a file and loading them
      into the model. Unless, you want to test against specific weights, these steps can be disabled without any
      drawbacks.
  
      Including this fixture into the signature of your test, i.e. `test_foo(disable_weight_loading)`, will recurse
      through all models in `torchvision.models` and will patch all occurrences of the function
      `download_state_dict_from_url` as well as the method `load_state_dict` on all subclasses of `nn.Module` to be
      no-ops.
  
      .. warning:
  
          Loaded models are still executable as normal, but will always have random weights. Make sure to not use this
          fixture if you want to compare the model output against reference values.
  
      """
      starting_point = models
      function_name = "load_state_dict_from_url"
      method_name = "load_state_dict"
  
      module_names = {
          info.name
          for info in pkgutil.walk_packages(
              starting_point.__path__, f"{starting_point.__name__}."
          )
      }
      targets = {
          f"torchvision._internally_replaced_utils.{function_name}",
          f"torch.nn.Module.{method_name}",
      }
      for name in module_names:
          module = sys.modules.get(name)
          if not module:
              continue
  
          if function_name in module.__dict__:
              targets.add(f"{module.__name__}.{function_name}")
  
          targets.update(
              {
                  f"{module.__name__}.{obj.__name__}.{method_name}"
                  for obj in module.__dict__.values()
                  if isinstance(obj, type)
                  and issubclass(obj, nn.Module)
                  and method_name in obj.__dict__
              }
          )
  
      for target in targets:
          # See https://github.com/pytorch/vision/pull/4867#discussion_r743677802 for details
          with contextlib.suppress(AttributeError):
              mocker.patch(target)
  
imports: import contextlib
  import functools
  import operator
  import os
  import pkgutil
  import platform
  import sys
  import warnings
  from collections import OrderedDict
  from tempfile import TemporaryDirectory
  from typing import Any
  import pytest
  import torch
  import torch.fx
  import torch.nn
  from _utils_internal import get_relative_path
  from common_utils import cpu_and_cuda, freeze_rng_state, map_nested_tensor_object, needs_cuda, set_rng_seed
  from PIL import Image
  from torchvision import models, transforms
  from torchvision.models import get_model_builder, list_models
label_desc: Use image node_id 3 for calling a global function with example usage: disable_weight_loading(mocker) without return types