code: def thinning_sampler(rng, lamb, xmin=0, lamb_min=1e-10):
      """
      Ogata's Thinning algorithm for time-varying exponential distribution with
      monotone-decreasing intensity function.
      """
      while lamb(xmin) > lamb_min:
          dx = -np.log(rng.rand()) / lamb(xmin)
          x = xmin + dx
          accept_rate = lamb(x) / lamb(xmin)
  
          if rng.rand() < accept_rate:
              return x
          xmin = x
      raise ValueError(
          f"require lamb({xmin})>{lamb_min} to guarantee cdf(infty)=1"
      )
  
label_desc: Use image node_id 1 for calling a global function with example usage: thinning_sampler(rng, lamb, xmin, lamb_min) and returns: x