keras/src/optimizers/schedules/learning_rate_schedule.py/PiecewiseConstantDecay/__call__
class PiecewiseConstantDecay:    def __call__(self, step):
        with ops.name_scope(self.name):
            boundaries = [ops.convert_to_tensor(x) for x in self.boundaries]
            values = [ops.convert_to_tensor(x) for x in self.values]
            step = ops.convert_to_tensor(step)

            for i, b in enumerate(boundaries):
                if b.dtype != step.dtype:
                    # We cast the boundaries to have the same type as the step
                    b = ops.cast(b, step.dtype)
                    boundaries[i] = b

            result_dtype = values[0].dtype
            result_value = ops.array(0, dtype=result_dtype)

            # For each range between boundaries, we check whether the step is
            # within that range, cast the resulting boolean to a number,
            # and multiply the result by the corresponding value for the range.
            # Taking the sum of these yields a piecewise constant function.
            step_less_than_first_boundary = ops.cast(
                step <= boundaries[0], result_dtype
            )
            result_value += step_less_than_first_boundary * values[0]

            step_greater_than_last_boundary = ops.cast(
                step > boundaries[-1], result_dtype
            )
            result_value += step_greater_than_last_boundary * values[-1]

            for low, high, value in zip(
                boundaries[:-1], boundaries[1:], values[1:-1]
            ):
                # Need to bind v here; can do this with lambda v=v: ...
                step_in_range = ops.cast(
                    (step > low) & (step <= high), result_dtype
                )
                result_value += step_in_range * value

            return result_value