code: def to_utc(df: DataFrame) -> DataFrame:
      """Either localizes the DataFrame Index to UTC or it applies
      tz_convert to set the Index to UTC.
      """
      if not df.empty:
          try:
              df.index = df.index.tz_localize("UTC")
          except TypeError:
              df.index = df.index.tz_convert("UTC")
      return df
  
file_path: pandas-ta/pandas_ta/utils/_time.py
imports: from datetime import datetime
  from time import localtime, perf_counter
  from typing import Tuple
  from pandas import DataFrame, Timestamp
  from pandas_ta import EXCHANGE_TZ, RATE
label_desc: Use image node_id 8 for calling a global function with example usage: to_utc(df) and returns: df