code: def sum_threshold(array, threshold):
      """Computes threshold index of decreasing nonnegative array by summing.
  
      This function takes in a decreasing array nonnegative floats, and a
      threshold between 0 and 1. It returns the index i at which the sum of the
      array up to i is threshold*total mass of the array.
  
      Args:
                array: a 1d numpy array of decreasing, nonnegative floats
                threshold: a number between 0 and 1
  
      Returns:
                i: index at which np.sum(array[:i]) >= threshold
      """
      assert (threshold >= 0) and (
          threshold <= 1
      ), "print incorrect threshold"
  
      for i in range(len(array)):
          if np.sum(array[:i]) / np.sum(array) >= threshold:
              return i
  
file_path: ecco/src/ecco/svcca_lib/cca_core.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: sum_threshold(array, threshold) and returns: i