class_docstr: DatasetBuilder for beir dataset.
class_docstr_tok: ["DatasetBuilder","for","beir","dataset","."]
docstr: Generates (query, passage) pair examples.
docstr_tok: ["Generates","(","query",",","passage",")","pair","examples","."]
code: def _generate_qrel_examples(
      self, pipeline, qrel_path, query_pipeline, passage_pipeline
  ):
      """Generates (query, passage) pair examples."""
      beam = tfds.core.lazy_imports.apache_beam
      qid_query = query_pipeline | "QidAsKey" >> beam.Map(
          lambda x: (x["query_id"], x)  # pylint: disable=g-long-lambda
      )
      docid_passage = passage_pipeline | "DocidAsKey" >> beam.Map(
          lambda x: (x["passage_id"], x)
      )
  
      # PCollection[qid, Tuple(docid, score)]
      qid_docid = (
          pipeline
          | beam.io.ReadFromText(qrel_path)
          | "Split" >> beam.Map(lambda x: x.strip().split("\t")[:3])
          | "FilterFirstLine"
          >> beam.Filter(lambda x: x[0] != "query-id")
          | "QidAsKeyAndDocid"
          >> beam.Map(lambda x: (x[0], (x[1], float(x[2]))))
      )
  
      def to_docid_query_fn(ex):
          rst = []
          for docid, score in ex["docids"]:
              rst.append(
                  (
                      docid,
                      {  # pylint: disable=g-complex-comprehension
                          **ex["query"][0],
                          "score": score,
                      },
                  )
              )
          return rst
  
      # PCollection[docid, Dict].
      # Dict.keys() = ['query_id', 'query', 'query_metadata', 'score']
      docid_query = (
          (
              {
                  "docids": qid_docid,
                  "query": qid_query,
              }
          )
          | "GroupByQid" >> beam.CoGroupByKey()
          | "DropQid" >> beam.Values()
          | "FilterEmptyQid"
          >> beam.Filter(lambda x: x["query"] and x["docids"])
          | "SetKeyDocid" >> beam.FlatMap(to_docid_query_fn)
      )
  
      return (
          (
              {
                  "query": docid_query,
                  "passage": docid_passage,
              }
          )
          | "GroupByDocid" >> beam.CoGroupByKey()
          | "DropDocid" >> beam.Values()
          | "FilterEmptyDocid"
          >> beam.Filter(lambda x: x["query"] and x["passage"])
          | "MergeQueryAndPassage"
          >> beam.Map(
              lambda x: {  # pylint: disable=g-long-lambda
                  **x["query"][0],
                  **x["passage"][0],
              }
          )
          | "GetHashKey" >> beam.Map(lambda x: (_get_hash(x), x))
      )
  
imports: from __future__ import annotations
  import functools
  import json
  import os
  from typing import Mapping
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 5 for calling the Builder obj's underlying member method code with example usage: obj._generate_qrel_examples(pipeline, qrel_path, query_pipeline, passage_pipeline) and returns: unknown, rst