code: def get_shuffle_seq_ref_function(
      score_computation_function, shuffle_func, one_hot_func=None
  ):
      def compute_scores_with_shuffle_seq_refs(
          task_idx,
          input_data_sequences,
          num_refs_per_seq,
          batch_size,
          seed=1,
          progress_update=None,
          pregen_refs=None,
      ):
          rng = np.random.RandomState(seed)
  
          if pregen_refs is None:
              to_run_input_data_seqs = []
              to_run_input_data_refs = []
              references_generated = 0
              for seq in input_data_sequences:
                  for i in range(num_refs_per_seq):
                      references_generated += 1
                      if (
                          progress_update is not None
                          and references_generated % progress_update
                          == 0
                      ):
                          print(
                              str(references_generated)
                              + " reference seqs generated"
                          )
                      if isinstance(seq, np.ndarray):
                          seq = seq.squeeze()
                      to_run_input_data_seqs.append(seq)
                      to_run_input_data_refs.append(
                          shuffle_func(seq, rng=rng)
                      )
          else:
              to_run_input_data_seqs = [
                  seq
                  for seq in input_data_sequences
                  for i in range(num_refs_per_seq)
              ]
              assert len(pregen_refs) == len(to_run_input_data_seqs), (
                  len(pregen_refs),
                  len(to_run_input_data_seqs),
              )
              to_run_input_data_refs = pregen_refs
  
          if one_hot_func is not None:
              if progress_update is not None:
                  print("One hot encoding sequences...")
              input_data_list = [one_hot_func(to_run_input_data_seqs)]
              input_references_list = [
                  one_hot_func(to_run_input_data_refs)
              ]
              if progress_update is not None:
                  print("One hot encoding done...")
          else:
              # the data is already one-hot encoded
              input_shape = list(input_data_sequences.shape)
              input_shape[0] = input_shape[0] * num_refs_per_seq
              input_shape = tuple(input_shape)
              input_data_list = [
                  np.reshape(
                      np.asarray(to_run_input_data_seqs), input_shape
                  )
              ]
              input_references_list = [
                  np.reshape(
                      np.asarray(to_run_input_data_refs), input_shape
                  )
              ]
          # wrap task_idx in a list if it was not in a list
          # (will unwrap later)
          if (hasattr(task_idx, "__iter__")) == False:
              list_wrapped_task_idx = [task_idx]
          else:
              list_wrapped_task_idx = task_idx
          the_scores = []
          for a_task in list_wrapped_task_idx:
              computed_scores = np.array(
                  score_computation_function(
                      task_idx=a_task,
                      input_data_list=input_data_list,
                      input_references_list=input_references_list,
                      batch_size=batch_size,
                      progress_update=progress_update,
                  )
              )
              computed_scores = np.reshape(
                  computed_scores,
                  [len(input_data_sequences), num_refs_per_seq]
                  + list(input_data_list[0].shape[1:]),
              )
              # take the mean over all the refs
              mean_scores = np.mean(computed_scores, axis=1)
              the_scores.append(mean_scores)
          # unwrap the scores if task_idx was not orginally a list
          if (hasattr(task_idx, "__iter__")) == False:
              the_scores = the_scores[0]
          return the_scores
  
      return compute_scores_with_shuffle_seq_refs
  
imports: from __future__ import division
  from __future__ import print_function
  from __future__ import absolute_import
  import sys
  import os
  import os.path
  import numpy
  from collections import namedtuple
  from collections import OrderedDict
  import json
  import deeplift
  import tensorflow
label_desc: Use image node_id 17 for calling a global function with example usage: get_shuffle_seq_ref_function(score_computation_function, shuffle_func, one_hot_func) and returns: compute_scores_with_shuffle_seq_refs, the_scores