code: def systematic_resampling(weights, rng):
      """
      Systematic resampling.
  
      Parameters
      ----------
      weights :
          The weights should be probabilities and the total sum should be 1.
  
      Returns
      -------
      new_indices: array
          A vector of indices in the interval 0, ..., len(normalized_weights)
      """
      lnw = len(weights)
      arange = np.arange(lnw)
      uniform = (rng.random(1) + arange) / lnw
  
      idx = 0
      weight_accu = weights[0]
      new_indices = np.empty(lnw, dtype=int)
      for i in arange:
          while uniform[i] > weight_accu:
              idx += 1
              weight_accu += weights[idx]
          new_indices[i] = idx
  
      return new_indices
  
imports: import abc
  import sys
  import warnings
  from abc import ABC
  from typing import Dict, Union, cast
  import numpy
  import pytensor.tensor
  from pytensor.graph.replace import clone_replace
  from scipy.special import logsumexp
  from scipy.stats import multivariate_normal
  from typing_extensions import TypeAlias
  from pymc.backends.ndarray import NDArray
  from pymc.blocking import DictToArrayBijection
  from pymc.initial_point import make_initial_point_expression
  from pymc.model import Point, modelcontext
  from pymc.pytensorf import compile_pymc, floatX, join_nonshared_inputs, make_shared_replacements
  from pymc.sampling.forward import draw
  from pymc.step_methods.metropolis import MultivariateNormalProposal
  from pymc.vartypes import discrete_types
label_desc: Use image node_id 1 for calling a global function with example usage: systematic_resampling(weights, rng) and returns: new_indices