code: def process_terms(
      n_classes,
      bagged_intercept,
      bagged_scores,
      bin_weights,
      bag_weights,
  ):
      n_bags = len(bag_weights)
      n_terms = len(bin_weights)
      for bag_idx in range(n_bags):
          term_scores = [
              bagged_tensor[bag_idx] for bagged_tensor in bagged_scores
          ]
          bagged_intercept[bag_idx] += process_bag_terms(
              n_classes, term_scores, bin_weights
          )
          for term_idx in range(n_terms):
              bagged_scores[term_idx][bag_idx] = term_scores[term_idx]
  
      term_scores = []
      standard_deviations = []
      if (bag_weights == bag_weights[0]).all():
          # if all the bags have the same total weight we can avoid some numeracy issues
          # by using a non-weighted standard deviation
          for scores in bagged_scores:
              averaged = np.average(scores, axis=0)
              term_scores.append(averaged)
  
              nans = np.isnan(averaged)
              stddevs = np.std(scores, axis=0)
              stddevs[np.isnan(stddevs)] = np.inf
              stddevs[nans] = np.nan
              standard_deviations.append(stddevs)
          intercept = np.average(bagged_intercept, axis=0)
      else:
          for scores in bagged_scores:
              averaged = np.average(scores, axis=0, weights=bag_weights)
              term_scores.append(averaged)
  
              nans = np.isnan(averaged)
              stddevs = _weighted_std(
                  scores, axis=0, weights=bag_weights
              )
              stddevs[np.isnan(stddevs)] = np.inf
              stddevs[nans] = np.nan
              standard_deviations.append(stddevs)
          intercept = np.average(
              bagged_intercept, axis=0, weights=bag_weights
          )
  
      if n_classes < 0:
          # scikit-learn requires float for regression. We have np.float64 from average.
          intercept = float(intercept)
      elif n_classes <= 2:
          # scikit-learn requires array for classification, but np.average collapses
          # to an np.float64 if input 1 dimensional, so restore to an array
          intercept = np.full(1, intercept, np.float64)
  
      return intercept, term_scores, standard_deviations
  
imports: from math import ceil, isnan, isinf, exp, log
  from ...utils._native import Native
  from ._tensor import restore_missing_value_zeros
  import numpy
  import warnings
  from itertools import islice
  import logging
label_desc: Use image node_id 5 for calling a global function with example usage: process_terms(n_classes, bagged_intercept, bagged_scores, bin_weights, bag_weights) and returns: intercept,  term_scores,  standard_deviations