docstr: this is a cumulative distribution function used for random sampling inputs
docstr_tok: ["this","is","a","cumulative","distribution","function","used","for","random","sampling","inputs"]
code: def _distribution_func(self, key, weights):
      """this is a cumulative distribution function used for random sampling inputs"""
      if key in self.saved_cum_distribution:
          return self.saved_cum_distribution[key]
  
      total = sum(weights)
      result = []
      cumsum = 0
      for w in weights:
          cumsum += w
          result.append(cumsum / total)
      self.saved_cum_distribution[key] = result
      return result
  
imports: import argparse
  import bisect
  import itertools
  import os
  import random
  import numpy
label_desc: Use image node_id 2 for calling the RandomSample obj's underlying member method code with example usage: obj._distribution_func(key, weights) and returns: result, self