class_docstr: Base class for the Sequential Monte Carlo kernels.
  
  To create a new SMC kernel you should subclass from this.
  
  Before sampling, the following methods are called once in order:
  
      initialize_population
          Choose initial population of SMC particles. Should return a dictionary
          with {var.name : numpy array of size (draws, var.size)}. Defaults
          to sampling from the prior distribution. This method is only called
          if `start` is not specified.
  
      _initialize_kernel : default
          Creates initial population of particles in the variable
          `self.tempered_posterior` and populates the `self.var_info` dictionary
          with information about model variables shape and size as
          {var.name : (var.shape, var.size)}.
  
          The functions `self.prior_logp_func` and `self.likelihood_logp_func` are
          created in this step. These expect a 1D numpy array with the summed
          sizes of each raveled model variable (in the order specified in
          :meth:`pymc.Model.initial_point`).
  
          Finally, this method computes the log prior and log likelihood for
          the initial particles, and saves them in `self.prior_logp` and
          `self.likelihood_logp`.
  
          This method should not be modified.
  
      setup_kernel : optional
          May include any logic that should be performed before sampling
          starts.
  
  During each sampling stage the following methods are called in order:
  
      update_beta_and_weights : default
          The inverse temperature self.beta is updated based on the `self.likelihood_logp`
          and `threshold` parameter.
  
          The importance `self.weights` of each particle are computed from the old and newly
          selected inverse temperature.
  
          The iteration number stored in `self.iteration` is updated by this method.
  
          Finally the model `log_marginal_likelihood` of the tempered posterior
          is updated from these weights.
  
      resample : default
          The particles in `self.posterior` are sampled with replacement based
          on `self.weights`, and the used resampling indexes are saved in
          `self.resampling_indexes`.
  
          The arrays `self.prior_logp` and `self.likelihood_logp` are rearranged according
          to the order of the resampled particles. `self.tempered_posterior_logp`
          is computed from these and the current `self.beta`.
  
      tune : optional
          May include logic that should be performed before every mutation step.
  
      mutate : REQUIRED
          Mutate particles in `self.tempered_posterior`.
  
          This method is further responsible to update the `self.prior_logp`,
          `self.likelihod_logp` and `self.tempered_posterior_logp`, corresponding
          to each mutated particle.
  
      sample_stats : default
          Returns important sampling_stats at the end of each stage in a dictionary
          format. This will be saved in the final InferenceData object under `sample_stats`.
  
  Finally, at the end of sampling the following methods are called:
  
      _posterior_to_trace : default
          Convert final population of particles to a posterior trace object.
          This method should not be modified.
  
      sample_settings : default
          Returns important sample_settings at the end of sampling in a dictionary
          format. This will be saved in the final InferenceData object under `sample_stats`.
docstr: Initialize the SMC_kernel class.
  
  Parameters
  ----------
  draws : int, default 2000
      The number of samples to draw from the posterior (i.e. last stage). Also the number of
      independent chains. Defaults to 2000.
  start : dict, or array of dict, default None
      Starting point in parameter space. It should be a list of dict with length `chains`.
      When None (default) the starting point is sampled from the prior distribution.
  model : Model (optional if in ``with`` context).
  random_seed : int, array_like of int, RandomState or Generator, optional
      Value used to initialize the random number generator.
  threshold : float, default 0.5
      Determines the change of beta from stage to stage, i.e.indirectly the number of stages,
      the higher the value of `threshold` the higher the number of stages. Defaults to 0.5.
      It should be between 0 and 1.
  
  Attributes
  ----------
  self.var_info : dict
      Dictionary that contains information about model variables shape and size.
docstr_tok: ["Initialize","the","SMC_kernel","class",".","Parameters","--","--","--","--","--","draws",":","int",",","default","2000","The","number","of","samples","to","draw","from","the","posterior","(","i.e",".","last","stage",")",".","Also","the","number","of","independent","chains",".","Defaults","to","2000.","start",":","dict",",","or","array","of","dict",",","default","None","Starting","point","in","parameter","space",".","It","should","be","a","list","of","dict","with","length","`","chains","`",".","When","None","(","default",")","the","starting","point","is","sampled","from","the","prior","distribution",".","model",":","Model","(","optional","if","in","``","with","``","context",")",".","random_seed",":","int",",","array_like","of","int",",","RandomState","or","Generator",",","optional","Value","used","to","initialize","the","random","number","generator",".","threshold",":","float",",","default","0.5","Determines","the","change","of","beta","from","stage","to","stage",",","i.e.indirectly","the","number","of","stages",",","the","higher","the","value","of","`","threshold","`","the","higher","the","number","of","stages",".","Defaults","to","0.5",".","It","should","be","between","0","and","1",".","Attributes","--","--","--","--","--","self.var_info",":","dict","Dictionary","that","contains","information","about","model","variables","shape","and","size","."]
code: def __init__(
      self,
      draws=2000,
      start=None,
      model=None,
      random_seed=None,
      threshold=0.5,
  ):
      """
      Initialize the SMC_kernel class.
  
      Parameters
      ----------
      draws : int, default 2000
          The number of samples to draw from the posterior (i.e. last stage). Also the number of
          independent chains. Defaults to 2000.
      start : dict, or array of dict, default None
          Starting point in parameter space. It should be a list of dict with length `chains`.
          When None (default) the starting point is sampled from the prior distribution.
      model : Model (optional if in ``with`` context).
      random_seed : int, array_like of int, RandomState or Generator, optional
          Value used to initialize the random number generator.
      threshold : float, default 0.5
          Determines the change of beta from stage to stage, i.e.indirectly the number of stages,
          the higher the value of `threshold` the higher the number of stages. Defaults to 0.5.
          It should be between 0 and 1.
  
      Attributes
      ----------
      self.var_info : dict
          Dictionary that contains information about model variables shape and size.
  
      """
  
      self.draws = draws
      self.start = start
      if threshold < 0 or threshold > 1:
          raise ValueError(
              f"Threshold value {threshold} must be between 0 and 1"
          )
      self.threshold = threshold
      self.model = model
      self.rng = np.random.default_rng(seed=random_seed)
  
      self.model = modelcontext(model)
      self.variables = self.model.value_vars
  
      self.var_info = {}
      self.tempered_posterior = None
      self.prior_logp = None
      self.likelihood_logp = None
      self.tempered_posterior_logp = None
      self.prior_logp_func = None
      self.likelihood_logp_func = None
      self.log_marginal_likelihood = 0
      self.beta = 0
      self.iteration = 0
      self.resampling_indexes = None
      self.weights = np.ones(self.draws) / self.draws
  
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 to create a new SMC_KERNEL object from inherited base classes: ABC with example: obj = SMC_KERNEL(draws, start, model, random_seed, threshold)