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".
code: def __init__(
      self,
      initializer="glorot_uniform",
      use_dynamic_slicing=False,
      max_sequence_length=None,
      **kwargs,
  ):
      # We need to have a default dtype of float32, since the inputs (which Keras
      # usually uses to infer the dtype) will always be int32.
      if "dtype" not in kwargs:
          kwargs["dtype"] = "float32"
  
      super(PositionEmbedding, self).__init__(**kwargs)
      if use_dynamic_slicing and max_sequence_length is None:
          raise ValueError(
              "If `use_dynamic_slicing` is True, `max_sequence_length` must be set."
          )
      self._max_sequence_length = max_sequence_length
      self._initializer = tf.keras.initializers.get(initializer)
      self._use_dynamic_slicing = use_dynamic_slicing
  
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 1 to create a new PositionEmbedding object from inherited base classes: tf.keras.layers with example: obj = PositionEmbedding(initializer, use_dynamic_slicing, max_sequence_length)