code: def select_new_region_of_interest(
      factorial_importance_analysis: pd.DataFrame,
      space: Space,
      threshold: float,
      n_levels: int,
  ) -> tuple[Space, dict]:
      """Select new region of interest and frozen parameter values based on factorial analysis.
  
      Parameters
      ----------
      factorial_importance_analysis: dict
          Marginal variance ratios on best levels of the factorial performance analysis.
          Should have format {'dim-name': <marginal variance ratio>, ...}
      space: ``orion.algo.space.Space``
          Space object representing the current region of interest.
      threshold: float
          Threshold of marginal variance ratio below which we should freeze a dimension.
  
      """
  
      frozen_param_values = {}
      new_space = Space()
      for key, dim in space.items():
          dim_importance_analysis = factorial_importance_analysis[
              factorial_importance_analysis["param"] == key
          ]
          if float(dim_importance_analysis["importance"]) < threshold:
              frozen_param_values[key] = sum(dim.interval()) / 2.0
          else:
              level = int(dim_importance_analysis["best_level"])
              low, high = dim.interval()
              intervals = (high - low) / n_levels
              new_low = low + intervals * (level - 1)
              new_space.register(
                  Real(dim.name, "uniform", new_low, intervals)
              )
  
      return new_space, frozen_param_values
  
imports: from __future__ import annotations
  import copy
  import logging
  from collections import defaultdict
  from typing import Sequence
  import numpy
  import pandas
  import scipy
  from packaging import version
  from orion.algo.base import BaseAlgorithm
  from orion.algo.mofa import sampler
  from orion.algo.mofa.transformer import Transformer
  from orion.algo.space import Real, Space
  from orion.core.utils.format_trials import dict_to_trial
  from orion.core.worker.trial import Trial
label_desc: Use image node_id 3 for calling a global function with example usage: select_new_region_of_interest(factorial_importance_analysis, space, threshold, n_levels) and returns: new_space,  frozen_param_values