code: def _expected_moment(f, samples, weights=None, order=1, tol=0.0):
      """calculate the (weighted) nth-order expected moment of a function
  
      Args:
          f (func): a function that takes a list and returns a number
          samples (list): a list of sample points
          weights (list, default=None): a list of sample weights
          order (int, default=1): the degree, a positive integer
          tol (float, default=0.0): a tolerance, where any ``weight <= tol`` is zero
  
      Returns:
          the weighted nth-order expected moment of f on a list of sample points
      """
      if order < 0:
          raise NotImplementedError
      if weights is None:
          y = [f(x) for x in samples]  # XXX: parallel map?
          return moment(y, weights, order)  # XXX: tol?
      # skip evaluation of f(x) if the corresponding weight <= tol
      if not sum(abs(w) > tol for w in weights):
          yw = ((0.0, 0.0),)
      else:  # XXX: parallel map?
          yw = [
              (f(x), w)
              for (x, w) in zip(samples, weights)
              if abs(w) > tol
          ]
      return moment(*zip(*yw), order=order)
  
imports: from mystic.math.stats import *
  from mystic.math.samples import *
  from mystic.math.integrate import *
  from mystic.symbolic import generate_solvers, generate_constraint, solve
  from mystic.symbolic import generate_conditions, generate_penalty
  from mystic.math import almostEqual
  from mystic.math.distance import Lnorm
  from numpy import asarray
label_desc: Use image node_id 11 for calling a global function with example usage: _expected_moment(f, samples, weights, order, tol) and returns: moment, moment