def _get_period_range_edges(first, last, offset, closed='<STR_LIT:left>', base=<NUM_LIT:0>):
if not all(isinstance(obj, pd.Period) for obj in [first, last]):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>first = first.to_timestamp()<EOL>last = last.to_timestamp()<EOL>adjust_first = not offset.onOffset(first)<EOL>adjust_last = offset.onOffset(last)<EOL>first, last = _get_timestamp_range_edges(first, last, offset,<EOL>closed=closed, base=base)<EOL>first = (first + adjust_first * offset).to_period(offset)<EOL>last = (last - adjust_last * offset).to_period(offset)<EOL>return first, last<EOL>
Adjust the provided `first` and `last` Periods to the respective Period of
the given offset that encompasses them.

Parameters
----------
first : pd.Period
    The beginning Period of the range to be adjusted.
last : pd.Period
    The ending Period of the range to be adjusted.
offset : pd.DateOffset
    The dateoffset to which the Periods will be adjusted.
closed : {'right', 'left'}, default None
    Which side of bin interval is closed.
base : int, default 0
    The "origin" of the adjusted Periods.

Returns
-------
A tuple of length 2, containing the adjusted pd.Period objects.