code: def rename_duplicates(dataset, name="unique_id") -> MatrixTable:
      """Rename duplicate column keys.
  
      .. include:: ../_templates/req_tstring.rst
  
      Examples
      --------
  
      >>> renamed = hl.rename_duplicates(dataset).cols()
      >>> duplicate_samples = (renamed.filter(renamed.s != renamed.unique_id)
      ...                             .select()
      ...                             .collect())
  
      Notes
      -----
  
      This method produces a new column field from the string column key by
      appending a unique suffix ``_N`` as necessary. For example, if the column
      key "NA12878" appears three times in the dataset, the first will produce
      "NA12878", the second will produce "NA12878_1", and the third will produce
      "NA12878_2". The name of this new field is parameterized by `name`.
  
      Parameters
      ----------
      dataset : :class:`.MatrixTable`
          Dataset.
      name : :class:`str`
          Name of new field.
  
      Returns
      -------
      :class:`.MatrixTable`
      """
  
      require_col_key_str(dataset, "rename_duplicates")
      ids = dataset.col_key[0].collect()
  
      mapping, new_ids = deduplicate(ids)
  
      if mapping:
          info(
              f'Renamed {len(mapping)} duplicate {plural("sample ID", len(mapping))}. Mangled IDs as follows:'
              + "".join(
                  f'\n  "{pre}" => "{post}"' for pre, post in mapping
              )
          )
      else:
          info("No duplicate sample IDs found.")
      return dataset.annotate_cols(
          **{name: hl.literal(new_ids)[hl.int(hl.scan.count())]}
      )
  
imports: from typing import Union
  import hail
  from hail.expr import Expression, expr_numeric, expr_array, expr_interval, expr_any, construct_expr, construct_variable
  from hail.expr.types import tlocus, tarray, tstr, tstruct, ttuple
  from hail.matrixtable import MatrixTable
  from hail.table import Table
  from hail.typecheck import typecheck, nullable, func_spec, oneof
  from hail.utils import Interval, Struct, new_temp_file, deduplicate
  from hail.utils.misc import plural
  from hail.utils.java import Env, info
  from hail import ir
label_desc: Use image node_id 10 for calling a global function with example usage: rename_duplicates(dataset, name) and returns: dataset