code: def flatten_params(space, params=None):
      """Return the params of the corresponding flat space
  
      If no params are passed, returns all flattened params.
      If params are passed, returns the corresponding flattened params.
  
      Parameters
      ----------
      space: Space object
          A space object from an experiment.
      params: list of str, optional
          The parameters to select from the search space. If the flattened search space
          contains flattened params such as ('y' -> 'y[0]', 'y[1]'), passing 'y' in the list of
          params will returned the flattened version ['y[0]', 'y[1]']
  
      Examples
      --------
      If space has x~uniform(0, 1) and y~uniform(0, 1, shape=(1, 2)).
      >>> flatten_params(space)
      ['x', 'y[0,0]', 'y[0,1]']
      >>> flatten_params(space, params=['x'])
      ['x']
      >>> flatten_params(space, params=['x', 'y'])
      ['x', 'y[0,0]', 'y[0,1]']
      >>> flatten_params(space, params=['x', 'y[0,1]'])
      ['x', 'y[0,1]']
      >>> flatten_params(space, params=['y[0,1]', 'x'])
      ['x', 'y[0,1]']
  
      Raises
      ------
      ValueError
          If one of the parameter names passed is not in the flattened space.
  
      """
      keys = set(space.keys())
      flattened_keys = set(
          build_required_space(
              space,
              dist_requirement="linear",
              type_requirement="numerical",
              shape_requirement="flattened",
          ).keys()
      )
  
      if params is None:
          return sorted(flattened_keys)
  
      flattened_params = []
      for param in params:
          if param not in flattened_keys and param not in keys:
              raise ValueError(
                  f"Parameter {param} not contained in space: {flattened_keys}"
              )
          elif param not in flattened_keys and param in keys:
              dim = space[param]
              flattened_params += [
                  f'{dim.name}[{",".join(map(str, index))}]'
                  for index in itertools.product(*map(range, dim.shape))
              ]
          else:
              flattened_params.append(param)
  
      return flattened_params
  
file_path: orion/src/orion/analysis/base.py
imports: import itertools
  from functools import reduce
  import numpy
  import pandas
  from sklearn.ensemble import AdaBoostRegressor, BaggingRegressor, ExtraTreesRegressor, GradientBoostingRegressor, RandomForestRegressor
  from orion.core.utils import format_trials
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 3 for calling a global function with example usage: flatten_params(space, params) and returns: flattened_params, sorted