class_docstr: Creates a positional embedding.
  
  This layer creates a positional embedding as described in "BERT: Pre-training
  of Deep Bidirectional Transformers for Language Understanding"
  (https://arxiv.org/abs/1810.04805).
  
  This layer can be set up to either create a statically shaped slice or a
  dynamically shaped slice. If `use_dynamic_slicing` is True, the input tensor
  can have a dynamic 1st dimension, while if `use_dynamic_slicing` is False the
  input size must be fixed.
  
  Attributes:
    use_dynamic_slicing: Whether to use the dynamic slicing path.
    max_sequence_length: The maximum size of the dynamic sequence. Only
      applicable if `use_dynamic_slicing` is True.
    initializer: The initializer to use for the embedding weights. Defaults to
      "glorot_uniform".
docstr: Implements build() for the layer.
docstr_tok: ["Implements","build","(",")","for","the","layer","."]
code: def build(self, input_shape):
      """Implements build() for the layer."""
      dimension_list = input_shape.as_list()
  
      if len(dimension_list) != 3:
          raise ValueError(
              "PositionEmbedding expects a 3-dimensional input tensor "
              "of shape [batch, sequence, width]"
          )
      seq_length = dimension_list[1]
      width = dimension_list[2]
  
      # If we are not using dynamic slicing, we must assume that the sequence
      # length is fixed and max_sequence_length should not be specified.
      if not self._use_dynamic_slicing:
          if seq_length is None:
              raise ValueError(
                  "PositionEmbedding must have `use_dynamic_slicing` set "
                  "to True (and max_sequence_length set) when the "
                  "sequence (1st) dimension of the input is None."
              )
          if self._max_sequence_length is not None:
              raise ValueError(
                  "When `use_dynamic_slicing` is False, max_sequence_length should "
                  "not be specified and we ought to use seq_length to get the "
                  "variable shape."
              )
  
      if self._max_sequence_length is not None:
          weight_sequence_length = self._max_sequence_length
      else:
          weight_sequence_length = seq_length
  
      self._position_embeddings = self.add_weight(
          "embeddings",
          shape=[weight_sequence_length, width],
          initializer=self._initializer,
      )
  
      super(PositionEmbedding, self).build(input_shape)
  
file_path: autodist/examples/benchmark/utils/modeling/layers/position_embedding.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from utils import tf_utils
label_desc: Use image node_id 3 for calling the PositionEmbedding obj's underlying member method code with example usage: obj.build(input_shape) without return types