code: def _adjust_dates_anchored(
      first, last, freq, closed="right", origin="start_day", offset=None
  ):
      # First and last offsets should be calculated from the start day to fix an
      # error cause by resampling across multiple days when a one day period is
      # not a multiple of the frequency. See GH 8683
      # To handle frequencies that are not multiple or divisible by a day we let
      # the possibility to define a fixed origin timestamp. See GH 31809
      origin_nanos = 0  # origin == "epoch"
      if origin == "start_day":
          origin_nanos = first.normalize().value
      elif origin == "start":
          origin_nanos = first.value
      elif isinstance(origin, pd.Timestamp):
          origin_nanos = origin.value
      origin_nanos += offset.value if offset else 0
  
      # GH 10117 & GH 19375. If first and last contain timezone information,
      # Perform the calculation in UTC in order to avoid localizing on an
      # Ambiguous or Nonexistent time.
      first_tzinfo = first.tzinfo
      last_tzinfo = last.tzinfo
      if first_tzinfo is not None:
          first = first.tz_convert("UTC")
      if last_tzinfo is not None:
          last = last.tz_convert("UTC")
  
      foffset = (first.value - origin_nanos) % freq.nanos
      loffset = (last.value - origin_nanos) % freq.nanos
  
      if closed == "right":
          if foffset > 0:
              # roll back
              fresult = first.value - foffset
          else:
              fresult = first.value - freq.nanos
  
          if loffset > 0:
              # roll forward
              lresult = last.value + (freq.nanos - loffset)
          else:
              # already the end of the road
              lresult = last.value
      else:  # closed == 'left'
          if foffset > 0:
              fresult = first.value - foffset
          else:
              # start of the road
              fresult = first.value
  
          if loffset > 0:
              # roll forward
              lresult = last.value + (freq.nanos - loffset)
          else:
              lresult = last.value + freq.nanos
      fresult = pd.Timestamp(fresult)
      lresult = pd.Timestamp(lresult)
      if first_tzinfo is not None:
          fresult = fresult.tz_localize("UTC").tz_convert(first_tzinfo)
      if last_tzinfo is not None:
          lresult = lresult.tz_localize("UTC").tz_convert(last_tzinfo)
      return fresult, lresult
  
imports: import pickle
  import numpy
  import pandas
  import cudf
  import cudf._lib.labeling
  import cudf.core.index
  from cudf._typing import DataFrameOrSeries
  from cudf.core.groupby.groupby import DataFrameGroupBy, GroupBy, SeriesGroupBy, _Grouping
  from cudf.core.tools.datetimes import _offset_alias_to_code, _unit_dtype_map
label_desc: Use image node_id 2 for calling a global function with example usage: _adjust_dates_anchored(first, last, freq, closed, origin, offset) and returns: fresult,  lresult