code: def merge_dfs(merge_to: str, stage: str, dfs: DFDict) -> pd.DataFrame:
      """Construct a multi-indexed DataFrame containing the values of `dfs` deemed necessary by
      `merge_to` and `stage`. This is the opposite of `split_merged_df`
  
      Parameters
      ----------
      merge_to: String
          Type of `merged_df` to produce. Should be one of the following: {"all_data", "all_inputs",
          "all_targets", "non_train_data", "non_train_inputs", "non_train_targets"}
      stage: String in {"pre_cv", "intra_cv}
          Feature engineering stage for which `merged_df` is requested
      dfs: Dict
          Mapping of dataset names to their DataFrame values. Keys in `dfs` should be a subset of
          {"train_data", "train_inputs", "train_targets", "validation_data", "validation_inputs",
          "validation_targets", "holdout_data", "holdout_inputs", "holdout_targets", "test_inputs"}
  
      Returns
      -------
      merged_df: pd.DataFrame
          Multi-indexed DataFrame, in which the first index is a string naming the dataset in `dfs`
          from which the corresponding data originates. The following index(es) are the original
          index(es) from the dataset in `dfs`. All primary indexes in `merged_df` will be one of the
          strings considered to be valid keys for `dfs`
  
      Raises
      ------
      ValueError
          If all the DataFrames that would have been used in `merged_df` are None. This can happen if
          requesting `merge_to="non_train_targets"` during `stage="pre_cv"` when there is no holdout
          dataset available. Under these circumstances, the holdout dataset targets would be the sole
          contents of `merged_df`, rendering `merged_df` invalid since the data is unavailable
  
      See Also
      --------
      names_for_merge: Describes how `stage` values differ"""
      df_names = names_for_merge(merge_to, stage)
      df_names = [
          _
          for _ in df_names
          if isinstance(dfs.get(_, None), pd.DataFrame)
      ]
      try:
          merged_df = pd.concat(
              [dfs[_] for _ in df_names], keys=df_names
          )
      except ValueError as _ex:
          raise ValueError(
              f"Merging {df_names} into {merge_to} does not produce DataFrame"
          ) from _ex
          # TODO: Add more specific error message for below scenario?
          # Tricky: This will be raised when `stage`="pre_cv" and `merge_to`="non_train..." if
          #   holdout/test data not available in `dfs`. May occur, for example, when using a step
          #   function that requests "non_train_inputs", with an `Environment` that has neither
          #   `holdout_dataset` nor `test_dataset` IF attempting to force the `EngineerStep`'s
          #   `stage`="pre_cv", instead of its default "intra_cv". This is correct behavior because
          #   "non_train_inputs" cannot be made under these circumstances; however, the precise cause
          #   of the problem may not be immediately apparent
      return merged_df
  
imports: from hyperparameter_hunter.keys.hashing import make_hash_sha256
  from hyperparameter_hunter.space.dimensions import Categorical, RejectedOptional
  from hyperparameter_hunter.utils.boltons_utils import remap, default_visit, default_enter
  from hyperparameter_hunter.utils.general_utils import subdict
  import ast
  from contextlib import suppress
  from inspect import getsource
  import numpy
  import pandas
  from typing import List, Callable, Dict, Union, Tuple
label_desc: Use image node_id 2 for calling a global function with example usage: merge_dfs(merge_to, stage, dfs) and returns: merged_df