code: def _flatten_single_level_multiindex(index):
      pd = _pandas_api.pd
      if isinstance(index, pd.MultiIndex) and index.nlevels == 1:
          (levels,) = index.levels
          (labels,) = _get_multiindex_codes(index)
          # ARROW-9096: use levels.dtype to match cast with original DataFrame
          dtype = levels.dtype
  
          # Cheaply check that we do not somehow have duplicate column names
          if not index.is_unique:
              raise ValueError("Found non-unique column index")
  
          return pd.Index(
              [
                  levels[_label] if _label != -1 else None
                  for _label in labels
              ],
              dtype=dtype,
              name=index.names[0],
          )
      return index
  
imports: import ast
  from collections.abc import Sequence
  from concurrent import futures
  import concurrent.futures.thread
  from copy import deepcopy
  from itertools import zip_longest
  import json
  import operator
  import re
  import warnings
  import numpy
  import pyarrow
  from pyarrow.lib import _pandas_api, frombytes
label_desc: Use image node_id 34 for calling a global function with example usage: _flatten_single_level_multiindex(index) and returns: index, pd