code: def get_sample_fns(sample_fn, tuples, state):
      # each sample fn returns number of positives
      sample_fns = []
  
      def complete_sample_fn(t, n):
          raw_data, data, labels = sample_fn(list(t), n)
          current_idx = state["current_idx"]
          # idxs = range(state['data'].shape[0], state['data'].shape[0] + n)
          idxs = range(current_idx, current_idx + n)
  
          if "<U" in str(raw_data.dtype):
              # String types: make sure both string types are of maximum length
              # to avoid string truncation. E.g., '<U308', '<U290' -> '<U308'
              max_dtype = max(
                  str(state["raw_data"].dtype), str(raw_data.dtype)
              )
              state["raw_data"] = state["raw_data"].astype(max_dtype)
              raw_data = raw_data.astype(max_dtype)
  
          state["t_idx"][t].update(idxs)
          state["t_nsamples"][t] += n
          state["t_positives"][t] += labels.sum()
          state["data"][idxs] = data
          state["raw_data"][idxs] = raw_data
          state["labels"][idxs] = labels
          state["current_idx"] += n
          if state["current_idx"] >= state["data"].shape[0] - max(
              1000, n
          ):
              prealloc_size = state["prealloc_size"]
              current_idx = data.shape[0]
              state["data"] = np.vstack(
                  (
                      state["data"],
                      np.zeros(
                          (prealloc_size, data.shape[1]), data.dtype
                      ),
                  )
              )
              state["raw_data"] = np.vstack(
                  (
                      state["raw_data"],
                      np.zeros(
                          (prealloc_size, raw_data.shape[1]),
                          raw_data.dtype,
                      ),
                  )
              )
              state["labels"] = np.hstack(
                  (
                      state["labels"],
                      np.zeros(prealloc_size, labels.dtype),
                  )
              )
          # This can be really slow
          # state['data'] = np.vstack((state['data'], data))
          # state['raw_data'] = np.vstack((state['raw_data'], raw_data))
          # state['labels'] = np.hstack((state['labels'], labels))
          return labels.sum()
  
      for t in tuples:
          sample_fns.append(lambda n, t=t: complete_sample_fn(t, n))
      return sample_fns
  
file_path: anchor/anchor/anchor_base.py
imports: from __future__ import print_function
  import numpy
  import operator
  import copy
  import sklearn
  import collections
label_desc: Use image node_id 8 for calling the AnchorBaseBeam obj's underlying member method code with example usage: obj.get_sample_fns(sample_fn, tuples, state) and returns: sample_fns, labels