class_docstr: Trainable layer that maps discrete tokens/IDs to vectors.
  
  Embedding layers are commonly used to map discrete data, like words in NLP,
  into vectors. Here is a canonical example::
  
      vocab_size = 5
      word_ids = np.array([1, 2, 3, 4], dtype=np.int32)  # word_ids < vocab_size
      embedding_layer = tl.Embedding(vocab_size, 32)
      embedding_layer.init(trax.shapes.signature(word_ids))
      embedded = embedding_layer(word_ids)  # embedded.shape = (4, 32)
class_docstr_tok: ["Trainable","layer","that","maps","discrete","tokens\/IDs","to","vectors",".","Embedding","layers","are","commonly","used","to","map","discrete","data",",","like","words","in","NLP",",","into","vectors",".","Here","is","a","canonical","example",":",":","vocab_size","=","5","word_ids","=","np.array","(","[","1",",","2",",","3",",","4","]",",","dtype=np.int32",")","#","word_ids","<","vocab_size","embedding_layer","=","tl.Embedding","(","vocab_size",",","32",")","embedding_layer.init","(","trax.shapes.signature","(","word_ids",")",")","embedded","=","embedding_layer","(","word_ids",")","#","embedded.shape","=","(","4",",","32",")"]
docstr: Randomly initializes this layer's weights.
docstr_tok: ["Randomly","initializes","this","layer","'s","weights","."]
code: def init_weights_and_state(self, input_signature):
      """Randomly initializes this layer's weights."""
      del input_signature
      shape_w = (self._vocab_size, self._d_feature)
      # TODO(lukaszkaiser): do we split self.rng for consistency? Add a method?
      w = self._kernel_initializer(shape_w, self.rng)
      if self._use_bfloat16:
          w = w.astype(jnp.bfloat16)
      self.weights = w
  
imports: from absl import logging
  import numpy
  import tensorflow
  from trax import fastmath
  from trax.fastmath import numpy
  from trax.layers import base
  from trax.layers import initializers
  from trax.layers.assert_shape import assert_shape
  from trax.layers.base import Fn
label_desc: Use image node_id 3 for calling the Embedding obj's underlying member method code with example usage: obj.init_weights_and_state(input_signature) without return types