code: def Hawkes(rng, background, kernel, xmin, xmax, N_max=1e6):
      """
      requires int x kernel(x)<infty.
      """
      X = []
      while len(X) < N_max:
          lamb = lambda x: background + np.sum(  # noqa
              [kernel(x - xi) if x >= xi else 0 for xi in X]
          )
          x = thinning_sampler(rng, lamb, max(X + [xmin]))
          if x > xmax:  # out of range
              return X
  
          X.append(x)
  
      raise ValueError(f"N>{N_max}; check if int_0^infty kernel < inf")
  
label_desc: Use image node_id 2 for calling a global function with example usage: Hawkes(rng, background, kernel, xmin, xmax, N_max) and returns: X