code: def _collapse_column_names(columns: pd.MultiIndex) -> pd.Index:
      """Reduce multi-index column names by removing layers with the same value."""
      dropables = [
          i for i, x in enumerate(zip(*columns)) if len(set(x)) == 1
      ]
      return columns.droplevel(dropables)
  
imports: import collections
  import dataclasses
  import itertools
  from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Union
  import numpy
  import pandas
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
  from google.protobuf import wrappers_pb2
  from google.protobuf import descriptor
  from google.protobuf import message
label_desc: Use image node_id 6 for calling a global function with example usage: _collapse_column_names(columns) and returns: columns