code: def test_shape(self, config_file, expected_shape):
      test_image = np.random.rand(*expected_shape)
      tempdir = self.data_dir
      filename = os.path.join(tempdir, "image.nii")
      nib.save(nib.Nifti1Image(test_image, np.eye(4)), filename)
  
      # generate default args in a JSON file
      logging_conf = os.path.join(
          os.path.dirname(__file__), "testing_data", "logging.conf"
      )
      def_args = {
          "config_file": "will be replaced by `config_file` arg",
          "logging_file": logging_conf,
      }
      def_args_file = os.path.join(tempdir, "def_args.json")
      ConfigParser.export_config_file(
          config=def_args, filepath=def_args_file
      )
  
      meta = {"datalist": [{"image": filename}], "window": (96, 96, 96)}
      # test YAML file
      meta_file = os.path.join(tempdir, "meta.yaml")
      ConfigParser.export_config_file(
          config=meta, filepath=meta_file, fmt="yaml"
      )
  
      # test MLFlow settings
      settings = {
          "handlers_id": DEFAULT_HANDLERS_ID,
          "configs": {
              "no_epoch": True,  # test override config in the settings file
              "evaluator": {
                  "_target_": "MLFlowHandler",
                  "tracking_uri": "$monai.utils.path_to_uri(@output_dir) + '/mlflow_override1'",
                  "iteration_log": "@no_epoch",
              },
          },
      }
      settings_file = os.path.join(tempdir, "mlflow.json")
      ConfigParser.export_config_file(
          config=settings, filepath=settings_file, fmt="json"
      )
  
      # test override with file, up case postfix
      overridefile1 = os.path.join(tempdir, "override1.JSON")
      with open(overridefile1, "w") as f:
          # test override with part of the overriding file
          json.dump({"move_net": "$@network_def.to(@device)"}, f)
      os.makedirs(os.path.join(tempdir, "jsons"), exist_ok=True)
      overridefile2 = os.path.join(tempdir, "jsons/override2.JSON")
      with open(overridefile2, "w") as f:
          # test override with the whole overriding file
          json.dump("Dataset", f)
  
      if sys.platform == "win32":
          override = "--network $@network_def.to(@device) --dataset#_target_ Dataset"
      else:
          override = f"--network %{overridefile1}#move_net --dataset#_target_ %{overridefile2}"
      device = (
          "$torch.device('cuda:0')"
          if torch.cuda.is_available()
          else "$torch.device('cpu')"
      )
      # test with `monai.bundle` as CLI entry directly
      cmd = "-m monai.bundle run --postprocessing#transforms#2#output_postfix seg"
      cmd += f" {override} --no_epoch False --output_dir {tempdir} --device {device}"
      la = (
          ["coverage", "run"]
          + cmd.split(" ")
          + ["--meta_file", meta_file]
          + ["--config_file", config_file]
      )
      test_env = os.environ.copy()
      print(
          f"CUDA_VISIBLE_DEVICES in {__file__}",
          test_env.get("CUDA_VISIBLE_DEVICES"),
      )
      command_line_tests(
          la
          + ["--args_file", def_args_file]
          + ["--tracking", settings_file]
      )
      loader = LoadImage(image_only=True)
      self.assertTupleEqual(
          loader(
              os.path.join(tempdir, "image", "image_seg.nii.gz")
          ).shape,
          expected_shape,
      )
      self.assertTrue(os.path.exists(f"{tempdir}/mlflow_override1"))
  
      tracking_uri = (
          path_to_uri(tempdir) + "/mlflow_override2"
      )  # test override experiment management configs
      # here test the script with `google fire` tool as CLI
      cmd = "-m fire monai.bundle.scripts run --tracking mlflow --evaluator#amp False"
      cmd += f" --tracking_uri {tracking_uri} {override} --output_dir {tempdir} --device {device}"
      la = (
          ["coverage", "run"]
          + cmd.split(" ")
          + ["--meta_file", meta_file]
          + ["--config_file", config_file]
      )
      command_line_tests(la)
      self.assertTupleEqual(
          loader(
              os.path.join(tempdir, "image", "image_trans.nii.gz")
          ).shape,
          expected_shape,
      )
      self.assertTrue(os.path.exists(f"{tempdir}/mlflow_override2"))
      # test the saved execution configs
      self.assertTrue(len(glob(f"{tempdir}/config_*.json")), 2)
  
imports: from __future__ import annotations
  import json
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  import unittest
  from glob import glob
  import nibabel
  import numpy
  import torch
  from parameterized import parameterized
  from monai.bundle import ConfigParser
  from monai.bundle.utils import DEFAULT_HANDLERS_ID
  from monai.transforms import LoadImage
  from monai.utils import path_to_uri
  from tests.utils import command_line_tests
label_desc: Use image node_id 5 for calling the TestBundleRun obj's underlying member method code with example usage: obj.test_shape(config_file, expected_shape) without return types