code: def tensor_or_size_from_json(
      json: Dict[str, Any]
  ) -> Union[torch.Tensor, torch.Size]:
      if json["__type"] == "Tensor":
          return tensor_from_json(json)
      elif json["__type"] == "torch_Size":
          return checked_cast(
              torch.Size,
              torch_type_from_str(
                  identifier=json["value"], type_name="Size"
              ),
          )
      else:
          raise JSONDecodeError(
              f"Expected json encoding of a torch.Tensor or torch.Size. 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 8 for calling a global function with example usage: tensor_or_size_from_json(json) and returns: tensor_from_json, checked_cast