def apply_embeddings(self, inputs):
    'NEZHA的embedding是token、segment两者embedding之和\n        '
    inputs = inputs[:]
    x = inputs.pop(0)
    if (self.segment_vocab_size > 0):
        s = inputs.pop(0)
    z = self.layer_norm_conds[0]
    x = self.apply(inputs=x, layer=Embedding, input_dim=self.vocab_size, output_dim=self.embedding_size, embeddings_initializer=self.initializer, mask_zero=True, name='Embedding-Token')
    if (self.segment_vocab_size > 0):
        if self.shared_segment_embeddings:
            name = 'Embedding-Token'
        else:
            name = 'Embedding-Segment'
        s = self.apply(inputs=s, layer=Embedding, input_dim=2, output_dim=self.embedding_size, embeddings_initializer=self.initializer, name=name)
        x = self.apply(inputs=[x, s], layer=Add, name='Embedding-Token-Segment')
    x = self.apply(inputs=self.simplify([x, z]), layer=LayerNormalization, conditional=(z is not None), hidden_units=self.layer_norm_conds[1], hidden_activation=self.layer_norm_conds[2], hidden_initializer=self.initializer, name='Embedding-Norm')
    x = self.apply(inputs=x, layer=Dropout, rate=self.dropout_rate, name='Embedding-Dropout')
    if (self.embedding_size != self.hidden_size):
        x = self.apply(inputs=x, layer=Dense, units=self.hidden_size, kernel_initializer=self.initializer, name='Embedding-Mapping')
    return x
NEZHA的embedding是token、segment两者embedding之和
def apply_embeddings(self, inputs):
    '\n        '
    inputs = inputs[:]
    x = inputs.pop(0)
    if (self.segment_vocab_size > 0):
        s = inputs.pop(0)
    z = self.layer_norm_conds[0]
    x = self.apply(inputs=x, layer=Embedding, input_dim=self.vocab_size, output_dim=self.embedding_size, embeddings_initializer=self.initializer, mask_zero=True, name='Embedding-Token')
    if (self.segment_vocab_size > 0):
        if self.shared_segment_embeddings:
            name = 'Embedding-Token'
        else:
            name = 'Embedding-Segment'
        s = self.apply(inputs=s, layer=Embedding, input_dim=2, output_dim=self.embedding_size, embeddings_initializer=self.initializer, name=name)
        x = self.apply(inputs=[x, s], layer=Add, name='Embedding-Token-Segment')
    x = self.apply(inputs=self.simplify([x, z]), layer=LayerNormalization, conditional=(z is not None), hidden_units=self.layer_norm_conds[1], hidden_activation=self.layer_norm_conds[2], hidden_initializer=self.initializer, name='Embedding-Norm')
    x = self.apply(inputs=x, layer=Dropout, rate=self.dropout_rate, name='Embedding-Dropout')
    if (self.embedding_size != self.hidden_size):
        x = self.apply(inputs=x, layer=Dense, units=self.hidden_size, kernel_initializer=self.initializer, name='Embedding-Mapping')
    return x