code: def generate_mixes(val, num_mixes, sourceid_to_exids, seed=0):
      """Generate lists of Example IDs to be mixed."""
      del val
      rs = np.random.RandomState(
          seed=seed
      )  # Make the selection deterministic
      sourceid_to_exids_dict = collections.defaultdict(list)
      for sourceid, exid in sourceid_to_exids:
          sourceid_to_exids_dict[sourceid].append(exid)
  
      # First, generate mixes ensuring that every example is used at least once.
      mixes = generate_mixes_using_all_examples(
          sourceid_to_exids_dict, rs
      )
      if len(mixes) > num_mixes:
          raise ValueError(
              "Requested {} mixes, but {} mixes needed to use all examples.".format(
                  num_mixes, len(mixes)
              )
          )
      else:
          # We need more mixes, so generate some random ones, then crop the excess
          # from the random mixes, ensuring that we preserve the mixes that use every
          # example at least once.
          num_mixes_remaining = num_mixes - len(mixes)
          random_example_mixes = generate_mixes_random_examples(
              sourceid_to_exids_dict, num_mixes_remaining, rs
          )
          # If the random mixes happened to include any of the mixes we already
          # generated, remove them.
          random_example_mixes -= mixes
          # Do a random crop.
          random_example_mixes_list = list(random_example_mixes)
          rs.shuffle(random_example_mixes_list)
          # Combine the two mix lists.
          unique_mixes = (
              list(mixes)
              + random_example_mixes_list[:num_mixes_remaining]
          )
  
      keyed_mixes = dict(enumerate(unique_mixes))
      exid_to_mixids = collections.defaultdict(list)
      for mixid, exids in keyed_mixes.items():
          for exid in exids:
              exid_to_mixids[exid].append(mixid)
      return exid_to_mixids
  
imports: import collections
  import copy
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: generate_mixes(val, num_mixes, sourceid_to_exids, seed) and returns: exid_to_mixids