code: def generation_step_from_json(
      generation_step_json: Dict[str, Any],
      # pyre-fixme[24]: Generic type `type` expects 1 type parameter, use
      #  `typing.Type` to avoid runtime subscripting errors.
      decoder_registry: Dict[str, Type] = CORE_DECODER_REGISTRY,
      # pyre-fixme[2]: Parameter annotation cannot contain `Any`.
      class_decoder_registry: Dict[
          str, Callable[[Dict[str, Any]], Any]
      ] = CORE_CLASS_DECODER_REGISTRY,
  ) -> GenerationStep:
      """Load generation step from JSON."""
      generation_step_json = (
          _convert_generation_step_keys_for_backwards_compatibility(
              generation_step_json
          )
      )
      kwargs = generation_step_json.pop("model_kwargs", None)
      gen_kwargs = generation_step_json.pop("model_gen_kwargs", None)
      completion_criteria = (
          transition_criteria_from_json(
              generation_step_json.pop("completion_criteria")
          )
          if "completion_criteria" in generation_step_json.keys()
          else []
      )
      generation_step = GenerationStep(
          model=object_from_json(
              generation_step_json.pop("model"),
              decoder_registry=decoder_registry,
              class_decoder_registry=class_decoder_registry,
          ),
          num_trials=generation_step_json.pop("num_trials"),
          min_trials_observed=generation_step_json.pop(
              "min_trials_observed", 0
          ),
          completion_criteria=completion_criteria
          if completion_criteria is not None
          else [],
          max_parallelism=(
              generation_step_json.pop("max_parallelism", None)
          ),
          enforce_num_trials=generation_step_json.pop(
              "enforce_num_trials", True
          ),
          model_kwargs=_decode_callables_from_references(
              object_from_json(
                  kwargs,
                  decoder_registry=decoder_registry,
                  class_decoder_registry=class_decoder_registry,
              ),
          )
          if kwargs
          else None,
          model_gen_kwargs=_decode_callables_from_references(
              object_from_json(
                  gen_kwargs,
                  decoder_registry=decoder_registry,
                  class_decoder_registry=class_decoder_registry,
              ),
          )
          if gen_kwargs
          else None,
          index=generation_step_json.pop("index", -1),
          should_deduplicate=generation_step_json.pop(
              "should_deduplicate", False
          ),
      )
      return generation_step
  
imports: import datetime
  from collections import OrderedDict
  from enum import Enum
  from inspect import isclass
  from logging import Logger
  from typing import Any, Callable, Dict, List, Optional, Tuple, Type
  import numpy
  import pandas
  import torch
  from ax.benchmark.problems.hpo.torchvision import PyTorchCNNTorchvisionBenchmarkProblem
  from ax.core.base_trial import BaseTrial
  from ax.core.data import Data
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun
  from ax.core.multi_type_experiment import MultiTypeExperiment
  from ax.core.parameter import Parameter
  from ax.core.parameter_constraint import OrderConstraint, ParameterConstraint, SumConstraint
  from ax.core.search_space import SearchSpace
  from ax.exceptions.storage import JSONDecodeError
  from ax.modelbridge.generation_strategy import GenerationNode, GenerationStep, GenerationStrategy
  from ax.modelbridge.model_spec import ModelSpec
  from ax.modelbridge.registry import _decode_callables_from_references
  from ax.modelbridge.transition_criterion import MaxGenerationParallelism, MaxTrials, MinimumPreferenceOccurances, MinimumTrialsInStatus, MinTrials, TransitionCriterion
  from ax.models.torch.botorch_modular.model import SurrogateSpec
  from ax.models.torch.botorch_modular.surrogate import Surrogate
  from ax.storage.json_store.decoders import batch_trial_from_json, botorch_component_from_json, tensor_from_json, trial_from_json
  from ax.storage.json_store.registry import CORE_CLASS_DECODER_REGISTRY, CORE_DECODER_REGISTRY
  from ax.utils.common.logger import get_logger
  from ax.utils.common.serialization import SerializationMixin
  from ax.utils.common.typeutils import checked_cast, not_none
  from ax.utils.common.typeutils_torch import torch_type_from_str
label_desc: Use image node_id 15 for calling a global function with example usage: generation_step_from_json(generation_step_json, decoder_registry, class_decoder_registry) and returns: generation_step