def _embed_chars(self, codepoints: tf.Tensor,
                   segment_ids: tf.Tensor) -> tf.Tensor:
    """Lookup character embeddings given integer Unicode codepoints."""

    with tf.variable_scope("char_embeddings"):
      embed_seq = self._embed_hash_buckets(
          ids=codepoints,
          embedding_size=self.config.hidden_size,
          num_hashes=self.config.num_hash_functions,
          num_buckets=self.config.num_hash_buckets,
          initializer_range=self.config.initializer_range)
      dropout_prob = (
          self.config.hidden_dropout_prob if self._is_training else 0.0)
      return bert_modeling.embedding_postprocessor(
          input_tensor=embed_seq,
          use_token_type=True,
          token_type_ids=segment_ids,
          token_type_vocab_size=self.config.type_vocab_size,
          token_type_embedding_name="segment_embeddings",
          use_position_embeddings=True,
          position_embedding_name="char_position_embeddings",
          initializer_range=self.config.initializer_range,
          max_position_embeddings=self.config.max_positions,
          dropout_prob=dropout_prob)
Lookup character embeddings given integer Unicode codepoints.
language/canine/modeling.py