code: def make_run(tmp_path: Path) -> Callable[..., Run]:
      def _make(
          id: int | None = None,
          dummy: bool = False,
          backend: Backend | None = None,
          seed: int = DEFAULT_SEED,
          modified: bool = False,
          budget: float = 0.0,
          loss: float | None = None,
          losses: dict[str, float] | list[float] | None = None,
          model_size: int | None = None,
          mem_usage: float | None = None,
          predictions: str
          | list[str]
          | dict[str, np.ndarray]
          | None = "ensemble",
      ) -> Run:
          if loss is not None and losses is not None:
              raise ValueError(
                  "Can only specify either `loss` or `losses`"
              )
  
          if isinstance(loss, dict):
              raise ValueError("Please use `losses` for dict of losses")
  
          if dummy:
              assert id is None
              id = 1
              if loss is None and losses is None:
                  losses = {"metric_0": 50_000}
  
          if id is None:
              id = np.random.randint(sys.maxsize)
  
          model_id = f"{seed}_{id}_{budget}"
  
          # Use this backend to set things up
          if backend is not None:
              runsdir = Path(backend.get_runs_directory())
          else:
              runsdir = tmp_path
  
          dir = runsdir / model_id
  
          if not dir.exists():
              dir.mkdir()
  
          # Populate if None
          if isinstance(predictions, str):
              predictions = [predictions]
  
          # Convert to dict
          if isinstance(predictions, list):
              preds = np.asarray([[0]])
              predictions = {kind: preds for kind in predictions}
  
          # Write them
          if isinstance(predictions, dict):
              for kind, val in predictions.items():
                  fname = f"predictions_{kind}_{seed}_{id}_{budget}.npy"
                  with (dir / fname).open("wb") as f:
                      np.save(f, val)
  
          run = Run(dir)
  
          if modified:
              assert (
                  predictions is not None
              ), "Can only modify if predictions"
              for k, v in run.recorded_mtimes.items():
                  run.recorded_mtimes[k] = v + 1e-4
  
          if loss is not None:
              losses = [loss]
  
          if isinstance(losses, list):
              losses = {
                  f"metric_{i}": loss for i, loss in enumerate(losses)
              }
  
          if isinstance(losses, dict):
              run.losses = losses
  
          if mem_usage is not None:
              run._mem_usage = mem_usage
  
          # MB
          if model_size is not None:
              n_bytes = int(model_size * math.pow(1024, 2))
              model_path = dir / f"{seed}.{id}.{budget}.model"
              with model_path.open("wb") as f:
                  f.write(bytearray(n_bytes))
  
          return run
  
      return _make
  
file_path: auto-sklearn/test/fixtures/ensemble_building.py
imports: from __future__ import annotations
  from typing import Any, Callable
  import copy
  import math
  import pickle
  import sys
  from pathlib import Path
  import numpy
  from autosklearn.automl import AutoML
  from autosklearn.automl_common.common.utils.backend import Backend
  from autosklearn.constants import BINARY_CLASSIFICATION
  from autosklearn.data.xy_data_manager import XYDataManager
  from autosklearn.ensemble_building import EnsembleBuilder, EnsembleBuilderManager, Run
  from autosklearn.metrics import Scorer, accuracy
  from pytest_cases import fixture
  from test.conftest import DEFAULT_SEED
label_desc: Use image node_id 1 for calling a global function with example usage: make_run(tmp_path) and returns: _make, run