def apply(self, inputs=None, layer=None, arguments=None, **kwargs):
    '通过apply调用层会自动重用同名层\n        inputs: 上一层的输出；\n        layer: 要调用的层类名；\n        arguments: 传递给layer.call的参数；\n        kwargs: 传递给层初始化的参数。\n        '
    if ((layer is Dropout) and (self.dropout_rate == 0)):
        return inputs
    if ((layer is MultiHeadAttention) and self.residual_attention_scores):
        kwargs['return_attention_scores'] = True
    arguments = (arguments or {})
    name = self.prefixed(kwargs.get('name'))
    kwargs['name'] = name
    if (name not in self.layers):
        layer = layer(**kwargs)
        name = layer.name
        self.layers[name] = layer
    if (inputs is None):
        return self.layers[name]
    else:
        if isinstance(self.layers[name], MultiHeadAttention):
            if (name in self.attention_caches):
                (k_cache, v_cache) = self.attention_caches[name]
                (k_name, v_name) = ((name + '-Cached-Key'), (name + '-Cached-Value'))
                k = Concatenate1D(name=k_name)([k_cache, inputs[1]])
                v = Concatenate1D(name=v_name)([v_cache, inputs[2]])
                inputs = ((inputs[:1] + [k, v]) + inputs[3:])
            if self.residual_attention_scores:
                if (self.attention_scores is not None):
                    if arguments.get('a_bias'):
                        a_bias = Add(name=(name + '-Attention-Bias'))([inputs[3], self.attention_scores])
                    else:
                        a_bias = self.attention_scores
                    inputs = ((inputs[:3] + [a_bias]) + inputs[4:])
                    arguments['a_bias'] = True
                (o, a) = self.layers[name](inputs, **arguments)
                self.attention_scores = a
                return o
        return self.layers[name](inputs, **arguments)
通过apply调用层会自动重用同名层
inputs: 上一层的输出；
layer: 要调用的层类名；
arguments: 传递给layer.call的参数；
kwargs: 传递给层初始化的参数。
def apply(self, inputs=None, layer=None, arguments=None, **kwargs):
    '通过apply调用层会自动重用同名层\n        inputs: 上一层的输出；\n        layer: 要调用的层类名；\n        arguments: 传递给layer.call的参数；\n        kwargs: 传递给层初始化的参数。\n        '
    if ((layer is Dropout) and (self.dropout_rate == 0)):
        return inputs
    if ((layer is MultiHeadAttention) and self.residual_attention_scores):
        kwargs['return_attention_scores'] = True
    arguments = (arguments or {})
    name = self.prefixed(kwargs.get('name'))
    kwargs['name'] = name
    if (name not in self.layers):
        layer = layer(**kwargs)
        name = layer.name
        self.layers[name] = layer
    if (inputs is None):
        return self.layers[name]
    else:
        if isinstance(self.layers[name], MultiHeadAttention):
            if (name in self.attention_caches):
                (k_cache, v_cache) = self.attention_caches[name]
                (k_name, v_name) = ((name + '-Cached-Key'), (name + '-Cached-Value'))
                k = Concatenate1D(name=k_name)([k_cache, inputs[1]])
                v = Concatenate1D(name=v_name)([v_cache, inputs[2]])
                inputs = ((inputs[:1] + [k, v]) + inputs[3:])
            if self.residual_attention_scores:
                if (self.attention_scores is not None):
                    if arguments.get('a_bias'):
                        a_bias = Add(name=(name + '-Attention-Bias'))([inputs[3], self.attention_scores])
                    else:
                        a_bias = self.attention_scores
                    inputs = ((inputs[:3] + [a_bias]) + inputs[4:])
                    arguments['a_bias'] = True
                (o, a) = self.layers[name](inputs, **arguments)
                self.attention_scores = a
                return o
        return self.layers[name](inputs, **arguments)