code: def figarch_weights_python(
      parameters: Float64Array, p: int, q: int, trunc_lag: int
  ) -> Float64Array:
      r"""
      Parameters
      ----------
      parameters : ndarray
          Model parameters of the form (phi, d, beta) where omega is the
          intercept, d is the fractional integration coefficient and phi and beta
          are parameters of the volatility process.
      p : int
          0 or 1 to indicate whether the model contains phi
      q : int
          0 or 1 to indicate whether the model contains beta
      trunc_lag : int
          Truncation lag for the ARCH approximations
  
      Returns
      -------
      lam : ndarray
          ARCH(:math:`\infty`) coefficients used to approximate model dynamics
      """
      phi = parameters[0] if p else 0.0
      d = parameters[1] if p else parameters[0]
      beta = parameters[p + q] if q else 0.0
  
      # Recursive weight computation
      lam = np.empty(trunc_lag)
      delta = np.empty(trunc_lag)
      lam[0] = phi - beta + d
      delta[0] = d
      for i in range(1, trunc_lag):
          delta[i] = (i - d) / (i + 1) * delta[i - 1]
          lam[i] = beta * lam[i - 1] + (delta[i] - phi * delta[i - 1])
  
      return lam
  
imports: from __future__ import annotations
  from arch.compat.numba import jit
  from abc import ABCMeta, abstractmethod
  from typing import cast
  import numpy
  from scipy.special import gammaln
  from arch.typing import Float64Array, Int32Array
  from arch.utility.array import AbstractDocStringInheritor
label_desc: Use image node_id 9 for calling a global function with example usage: figarch_weights_python(parameters, p, q, trunc_lag) and returns: lam