code: def generate_dt_features(
      input_df,
      dt_col,
      features,
      one_hot_features,
      freq,
      features_generated,
  ):
      """
      generate features related to datetime
      :param input_df: pandas dataframe
      :param dt_col: col name of the datetime in `input_df`
      :param features: same as the param in TSDataset interface
      :param one_hot_features: same as the param in TSDataset interface
      :param freq: data frequency
      :param features_generated:
  
      :return : df
      """
      # get feature generation candidate
      if isinstance(features, list):
          features_normal = set(features)
      if isinstance(features, str):
          if features == "auto":
              features_normal = set(
                  [
                      key
                      for key, value in FEATURE_INTERVAL.items()
                      if value >= freq
                  ]
              )
          if features == "all":
              features_normal = set(
                  [key for key in FEATURE_INTERVAL.keys()]
              )
      if one_hot_features is None:
          one_hot_features = []
      features_onehot = set(one_hot_features)
      features_normal = features_normal - features_onehot
  
      df = input_df.copy()
      field = df[dt_col]
      # spark3 does not automatically convert time types
      # related issue: https://github.com/intel-analytics/BigDL/issues/7246
      if not pd.api.types.is_datetime64_any_dtype(
          field
      ) and not pd.api.types.is_timedelta64_dtype(field):
          field = pd.to_datetime(field, errors="ignore")
  
      # built in time features
      for attr in TIME_FEATURE:
          if (
              attr not in features_onehot
              and attr not in features_normal
          ):
              continue
          if attr == "WEEKOFYEAR" and version.parse(
              pd.__version__
          ) >= version.parse("1.1.0"):
              field_datetime = pd.to_datetime(
                  field.values.astype(np.int64)
              )
              df[attr] = pd.Int64Index(
                  field_datetime.isocalendar().week
              )
          else:
              df[attr] = getattr(field.dt, attr.lower())
          features_generated.append(attr)
          if attr in features_onehot:
              df = _one_hot_encode_helper(
                  df, attr, FEATURE_BIN_NUM[attr], features_generated
              )
  
      # additional time features
      hour = field.dt.hour
      for attr in ADDITIONAL_TIME_FEATURE_HOUR:
          if (
              attr not in features_onehot
              and attr not in features_normal
          ):
              continue
          df[attr] = ADDITIONAL_TIME_FEATURE_HOUR[attr](hour)
          features_generated.append(attr)
  
      weekday = field.dt.weekday
      for attr in ADDITIONAL_TIME_FEATURE_WEEKDAY:
          if (
              attr not in features_onehot
              and attr not in features_normal
          ):
              continue
          df[attr] = ADDITIONAL_TIME_FEATURE_WEEKDAY[attr](weekday)
          features_generated.append(attr)
  
      return df
  
file_path: BigDL/python/chronos/src/bigdl/chronos/data/utils/feature.py
imports: import pandas
  import numpy
  from packaging import version
label_desc: Use image node_id 5 for calling a global function with example usage: generate_dt_features(input_df, dt_col, features, one_hot_features, freq, features_generated) and returns: df