code: def normalize(weights, mass="l2", zsum=False, zmass=1.0):
      """normalize a list of points (e.g. normalize to 1.0)
  
      Inputs:
          weights -- a list of sample weights
          mass -- float target of normalized weights (or string for Ln norm)
          zsum -- use counterbalance when mass = 0.0
          zmass -- member scaling when mass = 0.0
  
      Notes: if mass='l1', will use L1-norm; if mass='l2' will use L2-norm; etc.
      """
      try:
          mass = int(mass.lstrip("l"))
          fixed = False
      except AttributeError:
          fixed = True
      weights = asarray(
          list(weights)
      )  # XXX: faster to use x = array(x, copy=True) ?
  
      if fixed:
          w = sum(abs(weights))
      else:
          mass = int(min(200, mass))  # x**200 is ~ x**inf
          w = Lnorm(weights, mass)
          mass = 1.0
  
      if not w:
          if not zsum:
              return list(weights * 0.0)
          from numpy import inf, nan
  
          weights[weights == 0.0] = nan
          return list(weights * inf)  # protect against ZeroDivision
  
      if float(mass) or not zsum:
          w = weights / w  # FIXME: not "mean-preserving"
          if not fixed:
              return list(w)  # <- scaled so sum(abs(x)) = 1
          # REMAINING ARE fixed mean
          m = sum(w)
          w = mass * w
          if (
              not m
          ):  # XXX: do similar to zsum (i.e. shift) when sum(weights)==0 ?
              if not zsum:
                  return list(weights * 0.0)
              from numpy import inf, nan
  
              weights[weights == 0.0] = nan
              return list(weights * inf)  # protect against ZeroDivision
          return list(w / m)  # <- scaled so sum(x) = 1
  
      # force selected member to satisfy sum = 0.0
      zsum = -1
      weights[zsum] = -(sum(weights) - weights[zsum])
      mass = zmass
      return list(mass * weights / w)
  
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 34 for calling a global function with example usage: normalize(weights, mass, zsum, zmass) and returns: list, list, list, list, list, list, list