code: def GMM1(
      weights,
      mus,
      sigmas,
      low=None,
      high=None,
      q=None,
      rng=None,
      size=(),
  ):
      """Sample from truncated 1-D Gaussian Mixture Model"""
      weights, mus, sigmas = list(
          map(np.asarray, (weights, mus, sigmas))
      )
      assert len(weights) == len(mus) == len(sigmas)
      n_samples = int(np.prod(size))
      # n_components = len(weights)
      if low is None and high is None:
          # -- draw from a standard GMM
          active = np.argmax(
              rng.multinomial(1, weights, (n_samples,)), axis=1
          )
          samples = rng.normal(loc=mus[active], scale=sigmas[active])
      else:
          # -- draw from truncated components
          # TODO: one-sided-truncation
          low = float(low)
          high = float(high)
          if low >= high:
              raise ValueError("low >= high", (low, high))
          samples = []
          while len(samples) < n_samples:
              active = np.argmax(rng.multinomial(1, weights))
              draw = rng.normal(loc=mus[active], scale=sigmas[active])
              if low <= draw < high:
                  samples.append(draw)
      samples = np.reshape(np.asarray(samples), size)
      # print 'SAMPLES', samples
      if q is None:
          return samples
      else:
          return np.round(old_div(samples, q)) * q
  
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 3 for calling a global function with example usage: GMM1(weights, mus, sigmas, low, high, q, rng, size) and returns: samples, unknown