code: def rank_interactions(
      dataset,
      bag,
      init_scores,
      iter_term_features,
      exclude,
      calc_interaction_flags,
      max_cardinality,
      min_samples_leaf,
      create_interaction_flags,
      objective,
      experimental_params=None,
      n_output_interactions=0,
  ):
      try:
          interaction_strengths = []
          with InteractionDetector(
              dataset,
              bag,
              init_scores,
              create_interaction_flags,
              objective,
              experimental_params,
          ) as interaction_detector:
              for feature_idxs in iter_term_features:
                  if tuple(sorted(feature_idxs)) in exclude:
                      continue
                  strength = (
                      interaction_detector.calc_interaction_strength(
                          feature_idxs,
                          calc_interaction_flags,
                          max_cardinality,
                          min_samples_leaf,
                      )
                  )
                  item = (strength, feature_idxs)
                  if n_output_interactions <= 0:
                      interaction_strengths.append(item)
                  else:
                      if (
                          len(interaction_strengths)
                          == n_output_interactions
                      ):
                          heapq.heappushpop(interaction_strengths, item)
                      else:
                          heapq.heappush(interaction_strengths, item)
  
          interaction_strengths.sort(reverse=True)
          return interaction_strengths
      except Exception as e:
          return e
  
label_desc: Use image node_id 1 for calling a global function with example usage: rank_interactions(dataset, bag, init_scores, iter_term_features, exclude, calc_interaction_flags, max_cardinality, min_samples_leaf, create_interaction_flags, objective, experimental_params, n_output_interactions) and returns: interaction_strengths, e