code: def extract_index(data):
      index = None
      if len(data) == 0:
          index = Index([])
      elif len(data) > 0:
          raw_lengths = []
          indexes = []
  
          have_raw_arrays = False
          have_series = False
          have_dicts = False
  
          for val in data:
              if isinstance(val, ABCSeries):
                  have_series = True
                  indexes.append(val.index)
              elif isinstance(val, dict):
                  have_dicts = True
                  indexes.append(list(val.keys()))
              elif is_list_like(val) and getattr(val, "ndim", 1) == 1:
                  have_raw_arrays = True
                  raw_lengths.append(len(val))
  
          if not indexes and not raw_lengths:
              raise ValueError(
                  "If using all scalar values, you must pass"
                  " an index"
              )
  
          if have_series or have_dicts:
              index = _union_indexes(indexes)
  
          if have_raw_arrays:
              lengths = list(set(raw_lengths))
              if len(lengths) > 1:
                  raise ValueError("arrays must all be same length")
  
              if have_dicts:
                  raise ValueError(
                      "Mixing dicts with non-Series may lead to "
                      "ambiguous ordering."
                  )
  
              if have_series:
                  if lengths[0] != len(index):
                      msg = (
                          "array length {length} does not match index "
                          "length {idx_len}".format(
                              length=lengths[0], idx_len=len(index)
                          )
                      )
                      raise ValueError(msg)
              else:
                  index = ibase.default_index(lengths[0])
  
      return ensure_index(index)
  
imports: from collections import OrderedDict
  import numpy
  import numpy.ma
  from pandas._libs import lib
  from pandas._libs.tslibs import IncompatibleFrequency
  import pandas.compat
  from pandas.compat import get_range_parameters, lmap, lrange, raise_with_traceback, range
  from pandas.core.dtypes.cast import construct_1d_arraylike_from_scalar, construct_1d_ndarray_preserving_na, construct_1d_object_array_from_listlike, infer_dtype_from_scalar, maybe_cast_to_datetime, maybe_cast_to_integer_array, maybe_castable, maybe_convert_platform, maybe_infer_to_datetimelike, maybe_upcast
  from pandas.core.dtypes.common import is_categorical_dtype, is_datetime64tz_dtype, is_dtype_equal, is_extension_array_dtype, is_extension_type, is_float_dtype, is_integer_dtype, is_iterator, is_list_like, is_object_dtype, pandas_dtype
  from pandas.core.dtypes.generic import ABCDataFrame, ABCDatetimeIndex, ABCIndexClass, ABCPandasArray, ABCPeriodIndex, ABCSeries, ABCTimedeltaIndex
  from pandas.core.dtypes.missing import isna
  from pandas.core import algorithms, common
  from pandas.core.arrays import Categorical, ExtensionArray, period_array
  from pandas.core.index import Index, _get_objs_combined_axis, _union_indexes, ensure_index
  from pandas.core.indexes import base
  from pandas.core.internals import create_block_manager_from_arrays, create_block_manager_from_blocks
  from pandas.core.internals.arrays import extract_array
label_desc: Use image node_id 7 for calling a global function with example usage: extract_index(data) and returns: ensure_index