code: def test_ensemble_gpu_customization(self) -> None:
      test_path = self.test_dir.name
  
      dataroot = os.path.join(test_path, "dataroot")
      work_dir = os.path.join(test_path, "workdir")
  
      da_output_yaml = os.path.join(work_dir, "datastats.yaml")
      data_src_cfg = os.path.join(work_dir, "data_src_cfg.yaml")
  
      if not os.path.isdir(dataroot):
          os.makedirs(dataroot)
  
      if not os.path.isdir(work_dir):
          os.makedirs(work_dir)
  
      # Generate a fake dataset
      for d in fake_datalist["testing"] + fake_datalist["training"]:
          im, seg = create_test_image_3d(
              24, 24, 24, rad_max=10, num_seg_classes=1
          )
          nib_image = nib.Nifti1Image(im, affine=np.eye(4))
          image_fpath = os.path.join(dataroot, d["image"])
          nib.save(nib_image, image_fpath)
  
          if "label" in d:
              nib_image = nib.Nifti1Image(seg, affine=np.eye(4))
              label_fpath = os.path.join(dataroot, d["label"])
              nib.save(nib_image, label_fpath)
  
      # write to a json file
      fake_json_datalist = os.path.join(dataroot, "fake_input.json")
      ConfigParser.export_config_file(fake_datalist, fake_json_datalist)
  
      da = DataAnalyzer(
          fake_json_datalist, dataroot, output_path=da_output_yaml
      )
      da.get_all_case_stats()
  
      data_src = {
          "name": "fake_data",
          "task": "segmentation",
          "modality": "MRI",
          "datalist": fake_json_datalist,
          "dataroot": dataroot,
          "multigpu": False,
          "class_names": ["label_class"],
      }
  
      ConfigParser.export_config_file(data_src, data_src_cfg)
  
      with skip_if_downloading_fails():
          bundle_generator = BundleGen(
              algo_path=work_dir,
              data_stats_filename=da_output_yaml,
              data_src_cfg_name=data_src_cfg,
              templates_path_or_url=get_testing_algo_template_path(),
          )
  
      gpu_customization_specs = {
          "universal": {
              "num_trials": 1,
              "range_num_images_per_batch": [1, 2],
              "range_num_sw_batch_size": [1, 2],
          }
      }
      bundle_generator.generate(
          work_dir,
          num_fold=1,
          gpu_customization=True,
          gpu_customization_specs=gpu_customization_specs,
      )
      history = bundle_generator.get_history()
  
      for algo_dict in history:
          algo = algo_dict[AlgoKeys.ALGO]
          algo.train(train_param)
  
      builder = AlgoEnsembleBuilder(history, data_src_cfg)
      builder.set_ensemble_method(AlgoEnsembleBestN(n_best=2))
      ensemble = builder.get_ensemble()
      preds = ensemble(pred_param)
      self.assertTupleEqual(preds[0].shape, (2, 24, 24, 24))
  
      builder.set_ensemble_method(AlgoEnsembleBestByFold(1))
      ensemble = builder.get_ensemble()
      for algo in ensemble.get_algo_ensemble():
          print(algo[AlgoKeys.ID])
  
file_path: MONAI/tests/test_integration_gpu_customization.py
imports: from __future__ import annotations
  import os
  import tempfile
  import unittest
  import nibabel
  import numpy
  import torch
  from monai.apps.auto3dseg import AlgoEnsembleBestByFold, AlgoEnsembleBestN, AlgoEnsembleBuilder, BundleGen, DataAnalyzer
  from monai.bundle.config_parser import ConfigParser
  from monai.data import create_test_image_3d
  from monai.utils import optional_import
  from monai.utils.enums import AlgoKeys
  from tests.utils import SkipIfBeforePyTorchVersion, get_testing_algo_template_path, skip_if_downloading_fails, skip_if_no_cuda, skip_if_quick
label_desc: Use image node_id 2 for calling the TestEnsembleGpuCustomization obj's underlying member method code with example usage: obj.test_ensemble_gpu_customization() without return types