docstr: Function which parses query to passages correspondence file.
docstr_tok: ["Function","which","parses","query","to","passages","correspondence","file","."]
code: def parse_query_to_passages(self, file):
      """
      Function which parses query to passages correspondence file.
      """
      idx2psgs = {}
      idx = 0
      for line in open(file, "r").readlines():
          if "\t" not in line:
              raise ValueError(
                  f"Provided dataset does not have a form of tsv file"
              )
          query_and_psgs = line.split("\t")
          query_and_psgs_ids = [int(id_) for id_ in query_and_psgs]
          query_and_rel_psg_ids, irrel_psgs_ids = (
              query_and_psgs_ids[:2],
              query_and_psgs_ids[2:],
          )
          random.shuffle(irrel_psgs_ids)
          num_samples = len(irrel_psgs_ids) // self.num_negatives
          for j in range(num_samples):
              left = self.num_negatives * j
              right = self.num_negatives * (j + 1)
              idx2psgs[idx] = (
                  query_and_rel_psg_ids + irrel_psgs_ids[left:right]
              )
              idx += 1
      return idx2psgs
  
imports: import multiprocessing
  import os
  import pickle
  import random
  from typing import Optional
  import numpy
  from torch.utils.data import Dataset
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
label_desc: Use image node_id 4 for calling the BertInformationRetrievalDataset obj's underlying member method code with example usage: obj.parse_query_to_passages(file) and returns: idx2psgs