code: def probchoice2(items, probs, bincount=1000):
      """
      Puts items in bins in proportion to probs
      then uses random.choice() to select items.
  
      Larger bincount for more memory use but
      higher accuracy (on avarage).
      """
  
      bins = []
      for item, prob in zip(items, probs):
          bins += [item] * int(bincount * prob)
      while True:
          yield random.choice(bins)
  
imports: import random, bisect
label_desc: Use image node_id 2 for calling a global function with example usage: probchoice2(items, probs, bincount) without return types