code: def restrict_to_bounds(x, lower, upper):
      new_x = np.full_like(x, fill_value=np.nan, dtype=x.dtype)
      for i in range(x.size):
          lo = lower[i]
          up = upper[i]
          if x[i] < lo:
              new_x[i] = lo
          elif x[i] > up:
              new_x[i] = up
          else:
              new_x[i] = x[i]
      return new_x
  
imports: import math
  from collections import namedtuple
  from typing import Tuple
  import numpy
  from numba import njit
  from numba.typed import List
  from statsmodels.tsa.seasonal import seasonal_decompose
  from .utils import _calculate_intervals, CACHE, NOGIL
label_desc: Use image node_id 15 for calling a global function with example usage: restrict_to_bounds(x, lower, upper) and returns: new_x