code: def time_to_day_index(
      time_obj: Union[str, datetime], region: str = REG_CN
  ):
      if isinstance(time_obj, str):
          time_obj = datetime.strptime(time_obj, "%H:%M")
  
      if region == REG_CN:
          if CN_TIME[0] <= time_obj < CN_TIME[1]:
              return int((time_obj - CN_TIME[0]).total_seconds() / 60)
          elif CN_TIME[2] <= time_obj < CN_TIME[3]:
              return (
                  int((time_obj - CN_TIME[2]).total_seconds() / 60)
                  + 120
              )
          else:
              raise ValueError(
                  f"{time_obj} is not the opening time of the {region} stock market"
              )
      elif region == REG_US:
          if US_TIME[0] <= time_obj < US_TIME[1]:
              return int((time_obj - US_TIME[0]).total_seconds() / 60)
          else:
              raise ValueError(
                  f"{time_obj} is not the opening time of the {region} stock market"
              )
      elif region == REG_TW:
          if TW_TIME[0] <= time_obj < TW_TIME[1]:
              return int((time_obj - TW_TIME[0]).total_seconds() / 60)
          else:
              raise ValueError(
                  f"{time_obj} is not the opening time of the {region} stock market"
              )
      else:
          raise ValueError(f"{region} is not supported")
  
imports: import bisect
  from datetime import datetime, time, date, timedelta
  from typing import List, Optional, Tuple, Union
  import functools
  import re
  import pandas
  from qlib.config import C
  from qlib.constant import REG_CN, REG_TW, REG_US
label_desc: Use image node_id 3 for calling a global function with example usage: time_to_day_index(time_obj, region) and returns: int, unknown, int, int