code: def cal_sam_minute(
      x: pd.Timestamp, sam_minutes: int, region: str = REG_CN
  ) -> pd.Timestamp:
      """
      align the minute-level data to a down sampled calendar
  
      e.g. align 10:38 to 10:35 in 5 minute-level(10:30 in 10 minute-level)
  
      Parameters
      ----------
      x : pd.Timestamp
          datetime to be aligned
      sam_minutes : int
          align to `sam_minutes` minute-level calendar
      region: str
          Region, for example, "cn", "us"
  
      Returns
      -------
      pd.Timestamp:
          the datetime after aligned
      """
      cal = get_min_cal(C.min_data_shift, region)[::sam_minutes]
      idx = bisect.bisect_right(cal, x.time()) - 1
      _date, new_time = x.date(), cal[idx]
      return concat_date_time(_date, new_time)
  
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 6 for calling a global function with example usage: cal_sam_minute(x, sam_minutes, region) and returns: concat_date_time