def variable_mapping(self):
    '映射到官方T5权重格式\n        '
    mapping = {'Embedding-Token': ['shared/embedding'], 'Encoder-Embedding-Relative-Position': ['encoder/block_000/layer_000/SelfAttention/relative_attention_bias'], 'Encoder-Output-Norm': ['encoder/final_layer_norm/scale'], 'Decoder-Embedding-Relative-Position': ['decoder/block_000/layer_000/SelfAttention/relative_attention_bias'], 'Decoder-Output-Norm': ['decoder/final_layer_norm/scale']}
    for i in range(self.num_hidden_layers):
        prefix = ('encoder/block_%03d/' % i)
        mapping.update({('Encoder-Transformer-%d-MultiHeadSelfAttention' % i): [(prefix + 'layer_000/SelfAttention/q'), (prefix + 'layer_000/SelfAttention/k'), (prefix + 'layer_000/SelfAttention/v'), (prefix + 'layer_000/SelfAttention/o')], ('Encoder-Transformer-%d-MultiHeadSelfAttention-Norm' % i): [(prefix + 'layer_000/layer_norm/scale')], ('Encoder-Transformer-%d-FeedForward' % i): [(prefix + 'layer_001/DenseReluDense/wi/kernel'), (prefix + 'layer_001/DenseReluDense/wo/kernel')], ('Encoder-Transformer-%d-FeedForward-Norm' % i): [(prefix + 'layer_001/layer_norm/scale')]})
        prefix = ('decoder/block_%03d/' % i)
        mapping.update({('Decoder-Transformer-%d-MultiHeadSelfAttention' % i): [(prefix + 'layer_000/SelfAttention/q'), (prefix + 'layer_000/SelfAttention/k'), (prefix + 'layer_000/SelfAttention/v'), (prefix + 'layer_000/SelfAttention/o')], ('Decoder-Transformer-%d-MultiHeadSelfAttention-Norm' % i): [(prefix + 'layer_000/layer_norm/scale')], ('Decoder-Transformer-%d-MultiHeadCrossAttention' % i): [(prefix + 'layer_001/EncDecAttention/q'), (prefix + 'layer_001/EncDecAttention/k'), (prefix + 'layer_001/EncDecAttention/v'), (prefix + 'layer_001/EncDecAttention/o')], ('Decoder-Transformer-%d-MultiHeadCrossAttention-Norm' % i): [(prefix + 'layer_001/layer_norm/scale')], ('Decoder-Transformer-%d-FeedForward' % i): [(prefix + 'layer_002/DenseReluDense/wi/kernel'), (prefix + 'layer_002/DenseReluDense/wo/kernel')], ('Decoder-Transformer-%d-FeedForward-Norm' % i): [(prefix + 'layer_002/layer_norm/scale')]})
    if (self.version == 't5.1.1'):
        mapping['Encoder-Output-Norm'] = ['encoder/rms_norm/scale']
        mapping['Decoder-Output-Norm'] = ['decoder/rms_norm/scale']
        mapping['Decoder-Output-LM'] = ['decoder/logits/kernel']
        mapping = {k: [i.replace('layer_norm', 'rms_norm') for i in v] for (k, v) in mapping.items()}
        for i in range(self.num_hidden_layers):
            for layer in [('Encoder-Transformer-%d-FeedForward' % i), ('Decoder-Transformer-%d-FeedForward' % i)]:
                mapping[layer] = [((mapping[layer][0][:(- 7)] + '_0') + mapping[layer][0][(- 7):]), ((mapping[layer][0][:(- 7)] + '_1') + mapping[layer][0][(- 7):]), mapping[layer][1]]
    return mapping
映射到官方T5权重格式
def variable_mapping(self):
    '\n        '
    mapping = {'Embedding-Token': ['shared/embedding'], 'Encoder-Embedding-Relative-Position': ['encoder/block_000/layer_000/SelfAttention/relative_attention_bias'], 'Encoder-Output-Norm': ['encoder/final_layer_norm/scale'], 'Decoder-Embedding-Relative-Position': ['decoder/block_000/layer_000/SelfAttention/relative_attention_bias'], 'Decoder-Output-Norm': ['decoder/final_layer_norm/scale']}
    for i in range(self.num_hidden_layers):
        prefix = ('encoder/block_%03d/' % i)
        mapping.update({('Encoder-Transformer-%d-MultiHeadSelfAttention' % i): [(prefix + 'layer_000/SelfAttention/q'), (prefix + 'layer_000/SelfAttention/k'), (prefix + 'layer_000/SelfAttention/v'), (prefix + 'layer_000/SelfAttention/o')], ('Encoder-Transformer-%d-MultiHeadSelfAttention-Norm' % i): [(prefix + 'layer_000/layer_norm/scale')], ('Encoder-Transformer-%d-FeedForward' % i): [(prefix + 'layer_001/DenseReluDense/wi/kernel'), (prefix + 'layer_001/DenseReluDense/wo/kernel')], ('Encoder-Transformer-%d-FeedForward-Norm' % i): [(prefix + 'layer_001/layer_norm/scale')]})
        prefix = ('decoder/block_%03d/' % i)
        mapping.update({('Decoder-Transformer-%d-MultiHeadSelfAttention' % i): [(prefix + 'layer_000/SelfAttention/q'), (prefix + 'layer_000/SelfAttention/k'), (prefix + 'layer_000/SelfAttention/v'), (prefix + 'layer_000/SelfAttention/o')], ('Decoder-Transformer-%d-MultiHeadSelfAttention-Norm' % i): [(prefix + 'layer_000/layer_norm/scale')], ('Decoder-Transformer-%d-MultiHeadCrossAttention' % i): [(prefix + 'layer_001/EncDecAttention/q'), (prefix + 'layer_001/EncDecAttention/k'), (prefix + 'layer_001/EncDecAttention/v'), (prefix + 'layer_001/EncDecAttention/o')], ('Decoder-Transformer-%d-MultiHeadCrossAttention-Norm' % i): [(prefix + 'layer_001/layer_norm/scale')], ('Decoder-Transformer-%d-FeedForward' % i): [(prefix + 'layer_002/DenseReluDense/wi/kernel'), (prefix + 'layer_002/DenseReluDense/wo/kernel')], ('Decoder-Transformer-%d-FeedForward-Norm' % i): [(prefix + 'layer_002/layer_norm/scale')]})
    if (self.version == 't5.1.1'):
        mapping['Encoder-Output-Norm'] = ['encoder/rms_norm/scale']
        mapping['Decoder-Output-Norm'] = ['decoder/rms_norm/scale']
        mapping['Decoder-Output-LM'] = ['decoder/logits/kernel']
        mapping = {k: [i.replace('layer_norm', 'rms_norm') for i in v] for (k, v) in mapping.items()}
        for i in range(self.num_hidden_layers):
            for layer in [('Encoder-Transformer-%d-FeedForward' % i), ('Decoder-Transformer-%d-FeedForward' % i)]:
                mapping[layer] = [((mapping[layer][0][:(- 7)] + '_0') + mapping[layer][0][(- 7):]), ((mapping[layer][0][:(- 7)] + '_1') + mapping[layer][0][(- 7):]), mapping[layer][1]]
    return mapping