code: def marginal_mixture_logprob(
      op, values, rng, weights, *components, **kwargs
  ):
      (value,) = values
  
      # single component
      if len(components) == 1:
          # Need to broadcast value across mixture axis
          mix_axis = -components[0].owner.op.ndim_supp - 1
          components_logp = logp(
              components[0], pt.expand_dims(value, mix_axis)
          )
      else:
          components_logp = pt.stack(
              [logp(component, value) for component in components],
              axis=-1,
          )
  
      mix_logp = pt.logsumexp(
          pt.log(weights) + components_logp, axis=-1
      )
  
      mix_logp = check_parameters(
          mix_logp,
          0 <= weights,
          weights <= 1,
          pt.isclose(pt.sum(weights, axis=-1), 1),
          msg="0 <= weights <= 1, sum(weights) == 1",
      )
  
      return mix_logp
  
imports: import warnings
  import numpy
  import pytensor
  import pytensor.tensor
  from pytensor.graph.basic import Node, equal_computations
  from pytensor.tensor import TensorVariable
  from pytensor.tensor.random.op import RandomVariable
  from pymc.distributions import transforms
  from pymc.distributions.continuous import Gamma, LogNormal, Normal, get_tau_sigma
  from pymc.distributions.discrete import Binomial, NegativeBinomial, Poisson
  from pymc.distributions.dist_math import check_parameters
  from pymc.distributions.distribution import DiracDelta, Distribution, SymbolicRandomVariable, _moment, moment
  from pymc.distributions.shape_utils import _change_dist_size, change_dist_size
  from pymc.distributions.transforms import _default_transform
  from pymc.distributions.truncated import Truncated
  from pymc.logprob.abstract import _logcdf, _logcdf_helper, _logprob
  from pymc.logprob.basic import logp
  from pymc.logprob.transforms import IntervalTransform
  from pymc.pytensorf import floatX
  from pymc.util import check_dist_not_registered
  from pymc.vartypes import continuous_types, discrete_types
label_desc: Use image node_id 2 for calling a global function with example usage: marginal_mixture_logprob(op, values, rng, weights) and returns: mix_logp