class_docstr: Dataset iterator for multiparagraph-SQuAD dataset.
  
  reads data from jsonl files
  
  With ``with_answer_rate`` rate samples context with answer and with ``1 - with_answer_rate`` samples context
  from the same article, but without an answer. Contexts without an answer are sampled from uniform distribution.
  If ``with_answer_rate`` is None than we compute actual ratio for each data example.
  
  It extracts ``context``, ``question``, ``answer_text`` and ``answer_start`` position from dataset.
  Example from a dataset is a tuple of ``(context, question)`` and ``(answer_text, answer_start)``. If there is
  no answer in context, then ``answer_text`` is empty string and `answer_start` is equal to -1.
  
  Args:
      data: dict with keys ``'train'``, ``'valid'`` and ``'test'`` and values
      seed: random seed for data shuffling
      shuffle: whether to shuffle data during batching
      with_answer_rate: sampling rate of contexts with answer
      squad_rate: sampling rate of context from squad dataset (actual rate would be with_answer_rate * squad_rate)
  
  Attributes:
      shuffle: whether to shuffle data during batching
      random: instance of ``Random`` initialized with a seed
class_docstr_tok: ["Dataset","iterator","for","multiparagraph-SQuAD","dataset",".","reads","data","from","jsonl","files","With","``","with_answer_rate","``","rate","samples","context","with","answer","and","with","``","1","-","with_answer_rate","``","samples","context","from","the","same","article",",","but","without","an","answer",".","Contexts","without","an","answer","are","sampled","from","uniform","distribution",".","If","``","with_answer_rate","``","is","None","than","we","compute","actual","ratio","for","each","data","example",".","It","extracts","``","context","``",",","``","question","``",",","``","answer_text","``","and","``","answer_start","``","position","from","dataset",".","Example","from","a","dataset","is","a","tuple","of","``","(","context",",","question",")","``","and","``","(","answer_text",",","answer_start",")","``",".","If","there","is","no","answer","in","context",",","then","``","answer_text","``","is","empty","string","and","`","answer_start","`","is","equal","to","-1",".","Args",":","data",":","dict","with","keys","``","'train","'","``",",","``","'valid","'","``","and","``","'test","'","``","and","values","seed",":","random","seed","for","data","shuffling","shuffle",":","whether","to","shuffle","data","during","batching","with_answer_rate",":","sampling","rate","of","contexts","with","answer","squad_rate",":","sampling","rate","of","context","from","squad","dataset","(","actual","rate","would","be","with_answer_rate","*","squad_rate",")","Attributes",":","shuffle",":","whether","to","shuffle","data","during","batching","random",":","instance","of","``","Random","``","initialized","with","a","seed"]
code: def get_instances(
      self, data_type: str = "train"
  ) -> Tuple[Tuple[Tuple[str, str]], Tuple[List[str], List[int]]]:
      data_examples = []
      for f in self.data[data_type]:  # question, contexts, answers
          for line in f.open("r", encoding="utf8"):
              qcas = json.loads(line)
              question = qcas["question"]
              for context in qcas["contexts"]:
                  answer_text = [x["text"] for x in context["answer"]]
                  answer_start = [
                      x["answer_start"] for x in context["answer"]
                  ]
                  data_examples.append(
                      (
                          (context["context"], question),
                          (answer_text, answer_start),
                      )
                  )
      return tuple(zip(*data_examples))
  
file_path: DeepPavlov/deeppavlov/dataset_iterators/squad_iterator.py
imports: import json
  from typing import Dict, Any, List, Tuple, Generator, Optional
  import numpy
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.data_learning_iterator import DataLearningIterator
label_desc: Use image node_id 3 for calling the MultiSquadRetrIterator obj's underlying member method code with example usage: obj.get_instances(data_type) and returns: tuple