code: def test_load_weights(
      self, bundle_files, bundle_name, repo, device, model_file
  ):
      with skip_if_downloading_fails():
          # download bundle, and load weights from the downloaded path
          with tempfile.TemporaryDirectory() as tempdir:
              # load weights
              weights = load(
                  name=bundle_name,
                  model_file=model_file,
                  bundle_dir=tempdir,
                  repo=repo,
                  source="github",
                  progress=False,
                  device=device,
                  return_state_dict=True,
              )
              # prepare network
              with open(
                  os.path.join(tempdir, bundle_name, bundle_files[2])
              ) as f:
                  net_args = json.load(f)["network_def"]
              model_name = net_args["_target_"]
              del net_args["_target_"]
              model = getattr(nets, model_name)(**net_args)
              model.to(device)
              model.load_state_dict(weights)
              model.eval()
  
              # prepare data and test
              input_tensor = torch.load(
                  os.path.join(tempdir, bundle_name, bundle_files[4]),
                  map_location=device,
              )
              output = model.forward(input_tensor)
              expected_output = torch.load(
                  os.path.join(tempdir, bundle_name, bundle_files[3]),
                  map_location=device,
              )
              assert_allclose(
                  output,
                  expected_output,
                  atol=1e-4,
                  rtol=1e-4,
                  type_test=False,
              )
  
              # load instantiated model directly and test, since the bundle has been downloaded,
              # there is no need to input `repo`
              _model_2 = getattr(nets, model_name)(**net_args)
              model_2 = load(
                  name=bundle_name,
                  model=_model_2,
                  model_file=model_file,
                  bundle_dir=tempdir,
                  progress=False,
                  device=device,
                  source="github",
                  return_state_dict=False,
              )
              model_2.eval()
              output_2 = model_2.forward(input_tensor)
              assert_allclose(
                  output_2,
                  expected_output,
                  atol=1e-4,
                  rtol=1e-4,
                  type_test=False,
              )
  
              # test compatibility with return_state_dict=True.
              model_3 = load(
                  name=bundle_name,
                  model_file=model_file,
                  bundle_dir=tempdir,
                  progress=False,
                  device=device,
                  net_name=model_name,
                  source="github",
                  return_state_dict=False,
                  **net_args,
              )
              model_3.eval()
              output_3 = model_3.forward(input_tensor)
              assert_allclose(
                  output_3,
                  expected_output,
                  atol=1e-4,
                  rtol=1e-4,
                  type_test=False,
              )
  
imports: from __future__ import annotations
  import json
  import os
  import tempfile
  import unittest
  from unittest.case import skipUnless
  import numpy
  import torch
  from parameterized import parameterized
  import monai.networks.nets
  from monai.apps import check_hash
  from monai.bundle import ConfigParser, create_workflow, load
  from monai.utils import optional_import
  from tests.utils import SkipIfBeforePyTorchVersion, assert_allclose, command_line_tests, skip_if_downloading_fails, skip_if_no_cuda, skip_if_quick
label_desc: Use image node_id 1 for calling the TestLoad obj's underlying member method code with example usage: obj.test_load_weights(bundle_files, bundle_name, repo, device, model_file) without return types