code: def process_what_to_run_expand(
      pairs_to_test,
      random_counterpart=None,
      num_random_exp=100,
      random_concepts=None,
  ):
      """Get concept vs. random or random vs. random pairs to run.
  
        Given set of target, list of concept pairs, expand them to include
         random pairs. For instance [(t1, [c1, c2])...] becomes
         [(t1, [c1, random1],
          (t1, [c1, random2],...
          (t1, [c2, random1],
          (t1, [c2, random2],...]
  
      Args:
        pairs_to_test: [(target1, concept1), (target1, concept2), ...,
                        (target2, concept1), (target2, concept2), ...]
        random_counterpart: random concept that will be compared to the concept.
        num_random_exp: number of random experiments to run against each concept.
        random_concepts: A list of names of random concepts for the random
                         experiments to draw from. Optional, if not provided, the
                         names will be random500_{i} for i in num_random_exp.
  
      Returns:
        all_concepts: unique set of targets/concepts
        new_pairs_to_test: expanded
      """
  
      def get_random_concept(i):
          return (
              random_concepts[i]
              if random_concepts
              else "random500_{}".format(i)
          )
  
      new_pairs_to_test = []
      for target, concept_set in pairs_to_test:
          new_pairs_to_test_t = []
          # if only one element was given, this is to test with random.
          if len(concept_set) == 1:
              i = 0
              while len(new_pairs_to_test_t) < min(100, num_random_exp):
                  # make sure that we are not comparing the same thing to each other.
                  if concept_set[0] != get_random_concept(
                      i
                  ) and random_counterpart != get_random_concept(i):
                      new_pairs_to_test_t.append(
                          (
                              target,
                              [concept_set[0], get_random_concept(i)],
                          )
                      )
                  i += 1
          elif len(concept_set) > 1:
              new_pairs_to_test_t.append((target, concept_set))
          else:
              tf.compat.v1.logging.info("PAIR NOT PROCCESSED")
          new_pairs_to_test.extend(new_pairs_to_test_t)
  
      all_concepts = list(
          set(flatten([cs + [tc] for tc, cs in new_pairs_to_test]))
      )
  
      return all_concepts, new_pairs_to_test
  
file_path: tcav/tcav/utils.py
imports: from scipy.stats import ttest_ind
  import numpy
  import tensorflow
  from tcav.tcav_results.results_pb2 import Result, Results
label_desc: Use image node_id 3 for calling a global function with example usage: process_what_to_run_expand(pairs_to_test, random_counterpart, num_random_exp, random_concepts) and returns: all_concepts,  new_pairs_to_test, unknown