code: def flatten(
      parameter: core.Parameter,
      with_containers: bool = True,
      order: int = 0,
  ) -> tp.List[tp.Tuple[str, core.Parameter]]:
      """List all the instances involved as parameter (not as subparameter/
      endogeneous parameter)
  
      Parameter
      ---------
      parameter: Parameter
          the parameter to inspect
      with_containers: bool
          returns all the sub-parameter if True, otherwise only non-pure containers (i.e. only Data and Choice)
      order: int
          order of model/internal parameters to extract. With 0, no model/internal parameters is
          extracted, with 1, only 1st order are extracted, with 2, so model/internal parameters and
          their own model/internal parameters etc. Order 1 subparameters/endogeneous parameters
          include sigma for instance.
  
  
      Returns
      -------
      list
          a list of all (name, parameter) implied in this parameter, i.e all choices, items of dict
          and tuples etc (except if only_data=True). Names have a format "<index>.<key>" for a tuple
          containing dicts containing data for instance. Supbaramaters have # in their names.
          The parameters are sorted in the same way they would appear in the standard data.
  
      """
      flat = [("", parameter)]
      if isinstance(parameter, container.Container):
          content_to_add: tp.List[container.Container] = [parameter]
          if isinstance(
              parameter, container.Instrumentation
          ):  # special case: skip internal Tuple and Dict
              content_to_add = [parameter[0], parameter[1]]  # type: ignore
          for c in content_to_add:
              for k, p in sorted(c._content.items()):
                  content = flatten(
                      p, with_containers=with_containers, order=order
                  )
                  flat.extend(
                      (
                          str(k)
                          + (
                              ""
                              if not x
                              else (
                                  "." if not x.startswith("#") else ""
                              )
                              + x
                          ),
                          y,
                      )
                      for x, y in content
                  )
      if order > 0 and not isinstance(parameter, container.Container):
          subcontent = dict(parameter._subobjects.items())
          param = container.Dict(**subcontent)
          if len(subcontent) == 1:
              lone_content = next(iter(subcontent.values()))
              if isinstance(lone_content, container.Dict):
                  param = lone_content  # shorcut subparameters
          subparams = flatten(
              param, with_containers=False, order=order - 1
          )
          flat += [(f"#{x}", y) for x, y in subparams]
      if not with_containers:
          flat = [
              (x, y)
              for x, y in flat
              if isinstance(y, (pdata.Data, pchoice.BaseChoice))
          ]
      return flat
  
imports: import warnings
  import contextlib
  import itertools
  import numpy
  import nevergrad.common.typing
  from .None import core
  from .None import container
  from .None import _layering
  from .None import _datalayers
  from .None import data
  from .None import choice
  from .None import transforms
label_desc: Use image node_id 1 for calling a global function with example usage: flatten(parameter, with_containers, order) and returns: flat