docstr: Define predictions outputting the logits for range start and end.
  
  :param questions: The questions and context to predict on.
  :type questions: list[str]
  :param start: Whether to predict the start of the range.
  :type start: bool
  :return: The logits for the start and end of the range.
  :rtype: list[list[float]]
docstr_tok: ["Define","predictions","outputting","the","logits","for","range","start","and","end",".",":","param","questions",":","The","questions","and","context","to","predict","on",".",":","type","questions",":","list","[","str","]",":","param","start",":","Whether","to","predict","the","start","of","the","range",".",":","type","start",":","bool",":","return",":","The","logits","for","the","start","and","end","of","the","range",".",":","rtype",":","list","[","list","[","float","]","]"]
code: def predict_qa(self, questions, start):
      """Define predictions outputting the logits for range start and end.
  
      :param questions: The questions and context to predict on.
      :type questions: list[str]
      :param start: Whether to predict the start of the range.
      :type start: bool
      :return: The logits for the start and end of the range.
      :rtype: list[list[float]]
      """
      outs = []
      out_shape = None
      for q in questions:
          question, context = q.split(SEP)
          d = self._qa_model.tokenizer(question, context)
          device = self._qa_model.device
          out = self._qa_model.model.forward(
              **{
                  k: torch.tensor(d[k], device=device).reshape(1, -1)
                  for k in d
              }
          )
          logits = out.start_logits if start else out.end_logits
          out = logits.reshape(-1).detach().cpu().numpy()
          # shapes must match for mini batch, otherwise shap will error out
          # masking can produce different shapes in certain cases for some
          # models and tokenizers
          if out_shape is None:
              out_shape = out.shape[0]
          else:
              if out_shape != out.shape[0]:
                  if out.shape[0] < out_shape:
                      out_shape = out.shape[0]
                      for i in range(len(outs)):
                          outs[i] = outs[i][:out_shape]
                  out = out[:out_shape]
          outs.append(out)
      return outs
  
file_path: responsible-ai-toolbox/responsibleai_text/responsibleai_text/utils/question_answering.py
imports: import logging
  from responsibleai_text.common.constants import Tokens
label_desc: Use image node_id 2 for calling the QAPredictor obj's underlying member method code with example usage: obj.predict_qa(questions, start) and returns: outs