code: def LGMM1_lpdf(
      samples, weights, mus, sigmas, low=None, high=None, q=None
  ):
      samples, weights, mus, sigmas = list(
          map(np.asarray, (samples, weights, mus, sigmas))
      )
      assert weights.ndim == 1
      assert mus.ndim == 1
      assert sigmas.ndim == 1
      _samples = samples
      if samples.ndim != 1:
          samples = samples.flatten()
  
      if low is None and high is None:
          p_accept = 1
      else:
          p_accept = np.sum(
              weights
              * (
                  normal_cdf(high, mus, sigmas)
                  - normal_cdf(low, mus, sigmas)
              )
          )
  
      if q is None:
          # compute the lpdf of each sample under each component
          lpdfs = lognormal_lpdf(samples[:, None], mus, sigmas)
          rval = logsum_rows(lpdfs + np.log(weights))
      else:
          # compute the lpdf of each sample under each component
          prob = np.zeros(samples.shape, dtype="float64")
          for w, mu, sigma in zip(weights, mus, sigmas):
              if high is None:
                  ubound = samples + old_div(q, 2.0)
              else:
                  ubound = np.minimum(
                      samples + old_div(q, 2.0), np.exp(high)
                  )
              if low is None:
                  lbound = samples - old_div(q, 2.0)
              else:
                  lbound = np.maximum(
                      samples - old_div(q, 2.0), np.exp(low)
                  )
              lbound = np.maximum(0, lbound)
              # -- two-stage addition is slightly more numerically accurate
              inc_amt = w * lognormal_cdf(ubound, mu, sigma)
              inc_amt -= w * lognormal_cdf(lbound, mu, sigma)
              prob += inc_amt
          rval = np.log(prob) - np.log(p_accept)
      rval.shape = _samples.shape
      return rval
  
imports: from __future__ import print_function
  from __future__ import absolute_import
  from __future__ import division
  from builtins import str
  from builtins import map
  from builtins import zip
  from builtins import range
  from past.utils import old_div
  import logging
  import time
  import numpy
  from scipy.special import erf
  from .None import pyll
  from .pyll import scope
  from .pyll.stochastic import implicit_stochastic
  from .base import miscs_to_idxs_vals
  from .base import miscs_update_idxs_vals
  from .None import rand
label_desc: Use image node_id 11 for calling a global function with example usage: LGMM1_lpdf(samples, weights, mus, sigmas, low, high, q) and returns: rval