code: def batch_trial_from_json(
      experiment: core.experiment.Experiment,
      index: int,
      trial_type: Optional[str],
      status: TrialStatus,
      time_created: datetime,
      time_completed: Optional[datetime],
      time_staged: Optional[datetime],
      time_run_started: Optional[datetime],
      abandoned_reason: Optional[str],
      run_metadata: Optional[Dict[str, Any]],
      generator_run_structs: List[GeneratorRunStruct],
      runner: Optional[Runner],
      abandoned_arms_metadata: Dict[str, AbandonedArm],
      num_arms_created: int,
      status_quo: Optional[Arm],
      status_quo_weight_override: float,
      optimize_for_power: Optional[bool],
      # Allowing default values for backwards compatibility with
      # objects stored before these fields were added.
      failed_reason: Optional[str] = None,
      ttl_seconds: Optional[int] = None,
      generation_step_index: Optional[int] = None,
      properties: Optional[Dict[str, Any]] = None,
      stop_metadata: Optional[Dict[str, Any]] = None,
      **kwargs: Any,
  ) -> BatchTrial:
      """Load Ax BatchTrial from JSON.
  
      Other classes don't need explicit deserializers, because we can just use
      their constructors (see decoder.py). However, the constructor for Batch
      does not allow us to exactly recreate an existing object.
      """
  
      batch = BatchTrial(experiment=experiment, ttl_seconds=ttl_seconds)
      batch._index = index
      batch._trial_type = trial_type
      batch._status = status
      batch._time_created = time_created
      batch._time_completed = time_completed
      batch._time_staged = time_staged
      batch._time_run_started = time_run_started
      batch._abandoned_reason = abandoned_reason
      batch._failed_reason = failed_reason
      batch._run_metadata = run_metadata or {}
      batch._stop_metadata = stop_metadata or {}
      batch._generator_run_structs = generator_run_structs
      batch._runner = runner
      batch._abandoned_arms_metadata = abandoned_arms_metadata
      batch._num_arms_created = num_arms_created
      batch._status_quo = status_quo
      batch._status_quo_weight_override = status_quo_weight_override
      batch.optimize_for_power = optimize_for_power
      batch._generation_step_index = generation_step_index
      batch._properties = properties
      batch._refresh_arms_by_name()  # Trigger cache build
      warn_on_kwargs(callable_with_kwargs=BatchTrial, **kwargs)
      return batch
  
imports: from __future__ import annotations
  import inspect
  import logging
  from datetime import datetime
  from pathlib import Path
  from typing import Any, Dict, Iterable, List, Optional, Type, TYPE_CHECKING, Union
  import torch
  from ax.core.arm import Arm
  from ax.core.base_trial import TrialStatus
  from ax.core.batch_trial import AbandonedArm, BatchTrial, GeneratorRunStruct
  from ax.core.generator_run import GeneratorRun
  from ax.core.runner import Runner
  from ax.core.trial import Trial
  from ax.exceptions.storage import JSONDecodeError
  from ax.modelbridge.transforms.base import Transform
  from ax.storage.botorch_modular_registry import CLASS_TO_REVERSE_REGISTRY, REVERSE_INPUT_TRANSFORM_REGISTRY, REVERSE_OUTCOME_TRANSFORM_REGISTRY
  from ax.storage.transform_registry import REVERSE_TRANSFORM_REGISTRY
  from ax.utils.common.kwargs import warn_on_kwargs
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast
  from ax.utils.common.typeutils_torch import torch_type_from_str
  from botorch.models.transforms.input import ChainedInputTransform, InputTransform
  from botorch.models.transforms.outcome import ChainedOutcomeTransform, OutcomeTransform
label_desc: Use image node_id 1 for calling a global function with example usage: batch_trial_from_json(experiment, index, trial_type, status, time_created, time_completed, time_staged, time_run_started, abandoned_reason, run_metadata, generator_run_structs, runner, abandoned_arms_metadata, num_arms_created, status_quo, status_quo_weight_override, optimize_for_power, failed_reason, ttl_seconds, generation_step_index, properties, stop_metadata) and returns: batch