code: def filter_samples(samples, top_k, gold_key="gold_pos"):
      if top_k == None:
          return samples
  
      filtered_samples = [
          sample
          for sample in samples
          if sample[gold_key] > 0 and sample[gold_key] <= top_k
      ]
      return filtered_samples
  
imports: import os
  import io
  import sys
  import json
  import torch
  import logging
  import numpy
  from collections import OrderedDict
  from pytorch_transformers.modeling_utils import CONFIG_NAME, WEIGHTS_NAME
  from tqdm import tqdm
  from blink.candidate_ranking.bert_reranking import BertReranker
  from blink.biencoder.biencoder import BiEncoderRanker
label_desc: Use image node_id 2 for calling a global function with example usage: filter_samples(samples, top_k, gold_key) and returns: filtered_samples, samples