Stuck in schedule_lr_decay function

I am using this to calculate lr.
if epoch_num >= time_interval:
learning_rate = 1 * learning_rate0 / ( 1 + decay_rate * [epoch_num / time_interval] )
But, it gives me UnboundLocalError: local variable ‘learning_rate’ referenced before assignment while I use it.

Why do you need that “if” clause there? What happens if the condition turns out to be false? Looks like that would have the effect that learning_rate would not be defined at the return statement, right?