code: def _fix_legacy(parameter: Data) -> None:
      """Ugly hack for keeping the legacy behaviors with considers bounds always after the exponent
      and can still sample "before" the exponent (log-uniform).
      """
      from . import _datalayers
  
      legacy = [
          x
          for x in _datalayers.Operation.filter_from(parameter)
          if x._LEGACY
      ]
      if len(legacy) < 2:
          return
      if len(legacy) > 2:
          raise errors.NevergradRuntimeError(
              "More than 2 legacy layers, this should not happen, open an issue"
          )
      # warnings.warn(
      #     "Settings bounds and exponent through the Array/Scalar API will change behavior "
      #     " (this is an early warning, more on this asap)",
      #     errors.NevergradBehaviorChangesWarning,
      # )  # TODO activate when ready
      value = parameter.value
      layers_inds = tuple(leg._layer_index for leg in legacy)
      if abs(layers_inds[0] - layers_inds[1]) > 1:
          raise errors.NevergradRuntimeError(
              "Non-legacy layers between 2 legacy layers"
          )
      parameter._layers = [
          x
          for x in parameter._layers
          if x._layer_index not in layers_inds
      ]
      # fix parameter layers
      for k, sub in enumerate(parameter._layers):
          sub._layer_index = k
          sub._layers = parameter._layers
      parameter.value = value
      bound_ind = int(isinstance(legacy[0], _datalayers.Exponent))
      bound: _datalayers.BoundLayer = legacy[bound_ind]  # type: ignore
      exp: _datalayers.Exponent = legacy[(bound_ind + 1) % 2]  # type: ignore
      bound.bounds = tuple(None if b is None else exp.backward(b) for b in bound.bounds)  # type: ignore
      if isinstance(bound, _datalayers.Bound):
          bound = _datalayers.Bound(
              lower=bound.bounds[0],
              upper=bound.bounds[1],
              method=bound._method,
              uniform_sampling=bound.uniform_sampling,
          )
      for lay in (bound, exp):
          lay._layer_index = 0
          lay._layers = [lay]
          parameter.add_layer(lay)
      return
  
imports: import numpy
  import nevergrad.common.typing
  from nevergrad.common import errors
  from .None import _layering
  from .None import core
  from .container import Dict
  from .None import utils
label_desc: Use image node_id 2 for calling a global function with example usage: _fix_legacy(parameter) without return types