code: def match_start_or_end_of_period(
      time_granularity: TimeGranularity,
      date_to_match: pd.Timestamp,
      date_to_adjust: pd.Timestamp,
  ) -> pd.Timestamp:
      """Adjust date_to_adjust to be start or end of period based on if date_to_match is at start or end of period."""
      if is_period_start(time_granularity, date_to_match):
          return adjust_to_start_of_period(
              time_granularity, date_to_adjust
          )
      elif is_period_end(time_granularity, date_to_match):
          return adjust_to_end_of_period(
              time_granularity, date_to_adjust
          )
      else:
          raise ValueError(
              f"Expected `date_to_match` to fall at the start or end of the granularity period. Got '{date_to_match}' for granularity {time_granularity}."
          )
  
imports: from __future__ import annotations
  from datetime import date
  from typing import Union
  import pandas
  from dbt_semantic_interfaces.enum_extension import ExtendedEnum, assert_values_exhausted
  from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
label_desc: Use image node_id 9 for calling a global function with example usage: match_start_or_end_of_period(time_granularity, date_to_match, date_to_adjust) and returns: adjust_to_start_of_period, adjust_to_end_of_period