code: def _test_inferer(self, inferer):
      # should initialize before parsing any bundle content
      inferer.initialize()
      # test required and optional properties
      self.assertListEqual(inferer.check_properties(), [])
      # test read / write the properties, note that we don't assume it as JSON or YAML config here
      self.assertEqual(inferer.bundle_root, "will override")
      self.assertEqual(inferer.device, torch.device("cpu"))
      net = inferer.network_def
      self.assertTrue(isinstance(net, UNet))
      sliding_window = inferer.inferer
      self.assertTrue(isinstance(sliding_window, SlidingWindowInferer))
      preprocessing = inferer.preprocessing
      self.assertTrue(isinstance(preprocessing, Compose))
      postprocessing = inferer.postprocessing
      self.assertTrue(isinstance(postprocessing, Compose))
      # test optional properties get
      self.assertTrue(inferer.key_metric is None)
      inferer.bundle_root = "/workspace/data/spleen_ct_segmentation"
      inferer.device = torch.device(
          "cuda:0" if torch.cuda.is_available() else "cpu"
      )
      inferer.network_def = deepcopy(net)
      inferer.inferer = deepcopy(sliding_window)
      inferer.preprocessing = deepcopy(preprocessing)
      inferer.postprocessing = deepcopy(postprocessing)
      # test optional properties set
      inferer.key_metric = "set optional properties"
  
      # should initialize and parse again as changed the bundle content
      inferer.initialize()
      inferer.run()
      inferer.finalize()
      # verify inference output
      loader = LoadImage(image_only=True)
      pred_file = os.path.join(
          self.data_dir, "image", "image_seg.nii.gz"
      )
      self.assertTupleEqual(
          loader(pred_file).shape, self.expected_shape
      )
      os.remove(pred_file)
  
imports: from __future__ import annotations
  import os
  import shutil
  import tempfile
  import unittest
  from copy import deepcopy
  import nibabel
  import numpy
  import torch
  from parameterized import parameterized
  from monai.bundle import ConfigWorkflow
  from monai.data import Dataset
  from monai.inferers import SimpleInferer, SlidingWindowInferer
  from monai.networks.nets import UNet
  from monai.transforms import Compose, LoadImage
  from tests.nonconfig_workflow import NonConfigWorkflow
label_desc: Use image node_id 3 for calling the TestBundleWorkflow obj's underlying member method code with example usage: obj._test_inferer(inferer) without return types