class_docstr: Here, we use three networks to predict the start scores, end scores and answerable scores.
  
  We formulate p(start, end, answerable | contextual_embedding) as the product of the
  following three terms:
  
  - p(start | contextual_embedding)
  - p(end | start, contextual_embedding)
  - p(answerable | contextual_embedding)
  
  In the inference phase, we are able to use beam search to do the inference.
  
  use_segmentation is used to mark whether we segment the input sentence. In RoBERTa and XLMR,
  this flag is set to True, then the QA model no longer accept `token_types` as valid input.
  
  - use_segmentation=True:
      tokens :      <CLS> Question <SEP> Context <SEP>
      token_typess:  0       0       0      1      1
  
  - use_segmentation=False:
      tokens :      <CLS> Question <SEP> Context <SEP>
      token_typess:  None
class_docstr_tok: ["Here",",","we","use","three","networks","to","predict","the","start","scores",",","end","scores","and","answerable","scores",".","We","formulate","p","(","start",",","end",",","answerable","|","contextual_embedding",")","as","the","product","of","the","following","three","terms",":","-","p","(","start","|","contextual_embedding",")","-","p","(","end","|","start",",","contextual_embedding",")","-","p","(","answerable","|","contextual_embedding",")","In","the","inference","phase",",","we","are","able","to","use","beam","search","to","do","the","inference",".","use_segmentation","is","used","to","mark","whether","we","segment","the","input","sentence",".","In","RoBERTa","and","XLMR",",","this","flag","is","set","to","True",",","then","the","QA","model","no","longer","accept","`","token_types","`","as","valid","input",".","-","use_segmentation=True",":","tokens",":","<","CLS",">","Question","<","SEP",">","Context","<","SEP",">","token_typess",":","0","0","0","1","1","-","use_segmentation=False",":","tokens",":","<","CLS",">","Question","<","SEP",">","Context","<","SEP",">","token_typess",":","None"]
docstr: Parameters
  ----------
  contextual_embedding
      Shape (batch_size, sequence_length, C)
  start_positions
      Shape (batch_size, N)
      We process multiple candidates simultaneously
  p_mask
      Shape (batch_size, sequence_length)
  
  Returns
  -------
  end_logits
      Shape (batch_size, N, sequence_length)
docstr_tok: ["Parameters","--","--","--","--","--","contextual_embedding","Shape","(","batch_size",",","sequence_length",",","C",")","start_positions","Shape","(","batch_size",",","N",")","We","process","multiple","candidates","simultaneously","p_mask","Shape","(","batch_size",",","sequence_length",")","Returns","--","--","--","-","end_logits","Shape","(","batch_size",",","N",",","sequence_length",")"]
code: def get_end_logits(
      self, contextual_embedding, start_positions, p_mask
  ):
      """
  
      Parameters
      ----------
      contextual_embedding
          Shape (batch_size, sequence_length, C)
      start_positions
          Shape (batch_size, N)
          We process multiple candidates simultaneously
      p_mask
          Shape (batch_size, sequence_length)
  
      Returns
      -------
      end_logits
          Shape (batch_size, N, sequence_length)
      """
      # Select the features at the start_positions
      # start_feature will have shape (batch_size, N, C)
      start_features = select_vectors_by_position(
          contextual_embedding, start_positions
      )
      # Concatenate the start_feature and the contextual_embedding
      contextual_embedding = np.expand_dims(
          contextual_embedding, axis=1
      )  # (B, 1, T, C)
      start_features = np.expand_dims(
          start_features, axis=2
      )  # (B, N, 1, C)
      concat_features = np.concatenate(
          [
              npx.broadcast_like(
                  start_features, contextual_embedding, 2, 2
              ),
              npx.broadcast_like(
                  contextual_embedding, start_features, 1, 1
              ),
          ],
          axis=-1,
      )  # (B, N, T, 2C)
      end_scores = self.end_scores(concat_features)
      end_scores = np.squeeze(end_scores, -1)
      end_logits = masked_logsoftmax(
          end_scores, mask=np.expand_dims(p_mask, axis=1), axis=-1
      )
      return end_logits
  
file_path: gluon-nlp/scripts/question_answering/models.py
imports: import mxnet
  from mxnet import np, npx
  from mxnet.gluon import nn, HybridBlock
  from mxnet.util import use_np
  from gluonnlp.layers import get_activation
  from gluonnlp.op import select_vectors_by_position
  from gluonnlp.attention_cell import masked_logsoftmax, masked_softmax
label_desc: Use image node_id 3 for calling the ModelForQAConditionalV1 obj's underlying member method code with example usage: obj.get_end_logits(contextual_embedding, start_positions, p_mask) and returns: end_logits