code: def change_to_datetime_index_test(testdata, ts_column, str_format=""):
      testdata = copy.deepcopy(testdata)
      if str_format:
          print("Date_time string format given as %s" % str_format)
      else:
          print(
              '    Alert: No strf_time_format given for %s. Provide strf_time format during "setup" for better results.'
              % ts_column
          )
      ##### This is where we change the time index of test data #############
  
      try:
          if isinstance(testdata, pd.Series) or isinstance(
              testdata, pd.DataFrame
          ):
              if ts_column in testdata.columns:
                  ###### If the str_format is there, set the column as time series index ##
                  ts_index = testdata.pop(ts_column)
                  if str_format:
                      ts_index = pd.to_datetime(
                          ts_index, format=str_format
                      )
                  else:
                      ts_index = pd.to_datetime(ts_index)
                  testdata.index = ts_index
              elif ts_column in testdata.index.name:
                  ts_index = testdata.index
                  ### now set the index to datetime format
                  if str_format:
                      ts_index = pd.to_datetime(
                          ts_index, format=str_format
                      )
                  else:
                      ts_index = pd.to_datetime(ts_index)
                  testdata.index = ts_index
          elif type(testdata) == dask.dataframe.core.DataFrame:
              #### the below tests work for a dask dataframe as well ##
              if ts_column in testdata.columns:
                  ####### Now set the index to datetime index and drop the ts_colum #########
                  testdata.index = dd.to_datetime(
                      testdata[ts_column].compute()
                  )
                  testdata = testdata.drop(ts_column, axis=1)
              elif ts_column in testdata.index.name:
                  #### the above test works for a dask dataframe as well ##
                  ts_index = testdata.index
                  if type(testdata.index.compute().values[0]) in [
                      np.datetime64
                  ]:
                      ## it is already in date-time index format - do nothing
                      pass
                  else:
                      testdata.index = pd.to_datetime(
                          str_values, format=str_format
                      )
              else:
                  print(
                      "Error: Cannot detect %s either in columns or index. Please check input and try again."
                      % ts_column
                  )
          else:
              print(
                  "Unknown type of testdata. Please check input and try again."
              )
      except:
          print(
              "    converting testdata to datetime index erroring. Please check input and try again."
          )
      #### this is where we return the testdata and format
      return testdata, str_format
  
imports: from typing import List
  import numpy
  import pandas
  import copy
  import pdb
  from sklearn.model_selection import TimeSeriesSplit
  import dask
  import dask.dataframe
  import datetime
  from datetime import datetime, date, time
label_desc: Use image node_id 5 for calling a global function with example usage: change_to_datetime_index_test(testdata, ts_column, str_format) and returns: testdata,  str_format