<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def round_to_nearest(dt, n_round_sec=1.0):
 """Round datetime up or down to nearest divisor. Round datetime up or down to nearest number of seconds that divides evenly by the divisor. Any timezone is preserved but ignored in the rounding. Args: dt: datetime n_round_sec : int or float Divisor for rounding Examples: - ``n_round_sec`` = 0.1: nearest 10th of a second. - ``n_round_sec`` = 1: nearest second. - ``n_round_sec`` = 30: nearest half minute. """

    ts = ts_from_dt(strip_timezone(dt)) + n_round_sec / 2.0
    res = dt_from_ts(ts - (ts % n_round_sec))
    return res.replace(tzinfo=dt.tzinfo)