code: def tester(
      func=probchoice,
      items=("good", "bad" "ugly"),
      probs=(0.5, 0.3, 0.2),
      trials=100000,
  ):
      def problist2string(probs):
          """
          Turns a list of probabilities into a string
          Also rounds FP values
          """
          return ",".join("%8.6f" % (p,) for p in probs)
  
      counter = dict()
      it = func(items, probs)
      for dummy in range(trials):
          k = next(it)
          if k in counter:
              counter[k] += 1
          else:
              counter[k] = 1
      print("\n##\n##\n##")
      print("Trials:              ", trials)
      print("Items:               ", " ".join(items))
      print("Target probability:  ", problist2string(probs))
      print(
          "Attained probability:",
          problist2string(counter[x] / float(trials) for x in items),
      )
  
imports: import random, bisect
label_desc: Use image node_id 3 for calling a global function with example usage: tester(func, items, probs, trials) and returns: str