class_docstr: ## Index for retrieving nearest neighbors
class_docstr_tok: ["#","#","Index","for","retrieving","nearest","neighbors"]
docstr: #### Filter neighbors that overlap with the query
  
  The positions of the neighbors are given by `neighbor_offsets` and the position
  of the query chunk is `offset`.
docstr_tok: ["#","#","#","#","Filter","neighbors","that","overlap","with","the","query","The","positions","of","the","neighbors","are","given","by","`","neighbor_offsets","`","and","the","position","of","the","query","chunk","is","`","offset","`","."]
code: def filter_neighbors(self, offset: int, neighbor_offsets: List[int]):
      """
      #### Filter neighbors that overlap with the query
  
      The positions of the neighbors are given by `neighbor_offsets` and the position
      of the query chunk is `offset`.
      """
      return [
          n
          for n in neighbor_offsets
          if n < offset - (self.chunk_len + self.exclude_neighbor_span)
          or n > offset + (self.chunk_len + self.exclude_neighbor_span)
      ]
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/transformers/retro/database.py
imports: from typing import List, Optional
  import faiss
  import numpy
  import torch
  from labml import lab, monit
  from labml_helpers.datasets.text import TextFileDataset
  from labml_nn.transformers.retro.bert_embeddings import BERTChunkEmbeddings
label_desc: Use image node_id 2 for calling the RetroIndex obj's underlying member method code with example usage: obj.filter_neighbors(offset, neighbor_offsets) and returns: unknown