code: def tensor_from_json(json: Dict[str, Any]) -> torch.Tensor:
      try:
          device = (
              checked_cast(
                  torch.device,
                  torch_type_from_str(
                      identifier=json["device"]["value"],
                      type_name="device",
                  ),
              )
              if torch.cuda.is_available()
              else torch.device("cpu")
          )
          return torch.tensor(
              json["value"],
              dtype=checked_cast(
                  torch.dtype,
                  torch_type_from_str(
                      identifier=json["dtype"]["value"],
                      type_name="dtype",
                  ),
              ),
              device=device,
          )
      except KeyError as e:
          raise JSONDecodeError(
              f"Got KeyError {e} while attempting to construct a tensor from json. "
              f"Expected value, dtype, and device fields; got {json=}."
          )
  
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 7 for calling a global function with example usage: tensor_from_json(json) and returns: torch