class_docstr: Masked language model network head for BERT modeling.
  
  This network implements a masked language model based on the provided network.
  It assumes that the network being passed has a "get_embedding_table()" method.
  
  Attributes:
    input_width: The innermost dimension of the input tensor to this network.
    num_predictions: The number of predictions to make per sequence.
    source_network: The network with the embedding layer to use for the
      embedding layer.
    activation: The activation, if any, for the dense layer in this network.
    initializer: The intializer for the dense layer in this network. Defaults to
      a Glorot uniform initializer.
    output: The output style for this network. Can be either 'logits' or
      'predictions'.
class_docstr_tok: ["Masked","language","model","network","head","for","BERT","modeling",".","This","network","implements","a","masked","language","model","based","on","the","provided","network",".","It","assumes","that","the","network","being","passed","has","a","``","get_embedding_table","(",")","''","method",".","Attributes",":","input_width",":","The","innermost","dimension","of","the","input","tensor","to","this","network",".","num_predictions",":","The","number","of","predictions","to","make","per","sequence",".","source_network",":","The","network","with","the","embedding","layer","to","use","for","the","embedding","layer",".","activation",":","The","activation",",","if","any",",","for","the","dense","layer","in","this","network",".","initializer",":","The","intializer","for","the","dense","layer","in","this","network",".","Defaults","to","a","Glorot","uniform","initializer",".","output",":","The","output","style","for","this","network",".","Can","be","either","'logits","'","or","'predictions","'","."]
docstr: Gathers the vectors at the specific positions.
  
  Args:
      sequence_tensor: Sequence output of `BertModel` layer of shape
        (`batch_size`, `seq_length`, num_hidden) where num_hidden is number of
        hidden units of `BertModel` layer.
      positions: Positions ids of tokens in sequence to mask for pretraining
        of with dimension (batch_size, num_predictions) where
        `num_predictions` is maximum number of tokens to mask out and predict
        per each sequence.
  
  Returns:
      Masked out sequence tensor of shape (batch_size * num_predictions,
      num_hidden).
docstr_tok: ["Gathers","the","vectors","at","the","specific","positions",".","Args",":","sequence_tensor",":","Sequence","output","of","`","BertModel","`","layer","of","shape","(","`","batch_size","`",",","`","seq_length","`",",","num_hidden",")","where","num_hidden","is","number","of","hidden","units","of","`","BertModel","`","layer",".","positions",":","Positions","ids","of","tokens","in","sequence","to","mask","for","pretraining","of","with","dimension","(","batch_size",",","num_predictions",")","where","`","num_predictions","`","is","maximum","number","of","tokens","to","mask","out","and","predict","per","each","sequence",".","Returns",":","Masked","out","sequence","tensor","of","shape","(","batch_size","*","num_predictions",",","num_hidden",")","."]
code: def _gather_indexes(self, sequence_tensor, positions):
      """Gathers the vectors at the specific positions.
  
      Args:
          sequence_tensor: Sequence output of `BertModel` layer of shape
            (`batch_size`, `seq_length`, num_hidden) where num_hidden is number of
            hidden units of `BertModel` layer.
          positions: Positions ids of tokens in sequence to mask for pretraining
            of with dimension (batch_size, num_predictions) where
            `num_predictions` is maximum number of tokens to mask out and predict
            per each sequence.
  
      Returns:
          Masked out sequence tensor of shape (batch_size * num_predictions,
          num_hidden).
      """
      sequence_shape = tf_utils.get_shape_list(
          sequence_tensor, name="sequence_output_tensor"
      )
      batch_size, seq_length, width = sequence_shape
  
      flat_offsets = tf.keras.backend.reshape(
          tf.range(0, batch_size, dtype=tf.int32) * seq_length, [-1, 1]
      )
      flat_positions = tf.keras.backend.reshape(
          positions + flat_offsets, [-1]
      )
      flat_sequence_tensor = tf.keras.backend.reshape(
          sequence_tensor, [batch_size * seq_length, width]
      )
      output_tensor = tf.gather(flat_sequence_tensor, flat_positions)
  
      return output_tensor
  
file_path: autodist/examples/benchmark/utils/modeling/networks/masked_lm.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tensorflow.python.keras.engine import network
  from utils import tf_utils
label_desc: Use image node_id 3 for calling the MaskedLM obj's underlying member method code with example usage: obj._gather_indexes(sequence_tensor, positions) and returns: output_tensor