code: def _get_or_create_index(index, make_index, df):
      """Handles index creation logic base on user input"""
      index_was_created = False
  
      if index is None:
          # Case 1: user wanted to make index but did not specify column name
          assert (
              not make_index
          ), "Must specify an index name if make_index is True"
          # Case 2: make_index not specified but no index supplied, use first column
          warnings.warn(
              (
                  "Using first column as index. "
                  "To change this, specify the index parameter"
              ),
          )
          index = df.columns[0]
      elif make_index and index in df.columns:
          # Case 3: user wanted to make index but column already exists
          raise RuntimeError(
              f"Cannot make index: column with name {index} already present",
          )
      elif index not in df.columns:
          if not make_index:
              # Case 4: user names index, it is not in df. does not specify
              # make_index.  Make new index column and warn
              warnings.warn(
                  "index {} not found in dataframe, creating new "
                  "integer column".format(index),
              )
          # Case 5: make_index with no errors or warnings
          # (Case 4 also uses this code path)
          df = _create_index(df, index)
          index_was_created = True
      # Case 6: user specified index, which is already in df. No action needed.
      return index_was_created, index, df
  
imports: import copy
  import logging
  import warnings
  from collections import defaultdict
  import numpy
  import pandas
  from woodwork import init_series
  from woodwork.logical_types import Datetime, LatLong
  from featuretools.entityset import deserialize, serialize
  from featuretools.entityset.relationship import Relationship, RelationshipPath
  from featuretools.feature_base.feature_base import _ES_REF
  from featuretools.utils.gen_utils import Library, import_or_none, is_instance
  from featuretools.utils.plot_utils import check_graphviz, get_graphviz_format, save_graph
  from featuretools.utils.wrangle import _check_timedelta
label_desc: Use image node_id 2 for calling a global function with example usage: _get_or_create_index(index, make_index, df) and returns: index_was_created,  index,  df