code: def merge_optimizer_name_pattern(
      df: utils.Selector,
      pattern: str,
      merge_parametrization: bool = False,
      remove_suffix: bool = False,
  ) -> utils.Selector:
      """Merge the optimizer name with other descriptors based on a pattern
      Nothing happens if merge_parametrization is false and pattern is empty string
      """
      if merge_parametrization:
          if pattern:
              raise ValueError(
                  "Cannot specify both merge-pattern and merge-parametrization "
                  "(merge-parametrization is equivalent to merge-pattern='{optimizer_name},{parametrization}')"
              )
          pattern = _PARAM_MERGE_PATTERN
      if not pattern:
          return df
      df = df.copy()
      okey = "optimizer_name"
      elements = [
          tup[1]
          for tup in string.Formatter().parse(pattern)
          if tup[1] is not None
      ]
      assert okey in elements, (
          f"Missing optimizer key {okey!r} in merge pattern.\nEg: "
          + 'pattern="{optimizer_name}_{parametrization}"'
      )
      others = [x for x in elements if x != okey]
      aggregate = PatternAggregate(pattern)
      sub = df.loc[:, elements].fillna("")
      if len(sub.unique(others)) > 1:
          for optim in sub.unique(okey):
              inds = sub.loc[:, okey] == optim
              if len(sub.loc[inds, :].unique(others)) > 1:
                  df.loc[inds, okey] = sub.loc[inds, elements].agg(
                      aggregate, axis=1
                  )
      if remove_suffix:
          df["optimizer_name"] = df["optimizer_name"].replace(
              r"[0-9\.\-]*$", "", regex=True
          )
      return df.drop(columns=others)
  
imports: import os
  import re
  import string
  import hashlib
  import warnings
  import argparse
  import itertools
  from collections import defaultdict
  from pathlib import Path
  import numpy
  import pandas
  from matplotlib import pyplot
  from matplotlib.legend import Legend
  from matplotlib import cm
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  import nevergrad.common.typing
  from .None import utils
  from .exporttable import export_table
label_desc: Use image node_id 7 for calling a global function with example usage: merge_optimizer_name_pattern(df, pattern, merge_parametrization, remove_suffix) and returns: df, df