def clean_mtproto_tag(config, group_index):
    """
    清理mtproto 协议减少时无用的tag
    """
    if 'tag' in config['inbounds'][group_index]:
        tag = config['inbounds'][group_index]['tag']
        rules = config['routing']['rules']
        for index, rule in enumerate(rules):
            if rule['outboundTag'] != 'tg-out':
                continue
            if len(rule['inboundTag']) == 1:
                del rules[index]
                for out_index, oubound_mtproto in enumerate(config['outbounds']
                    ):
                    if oubound_mtproto['protocol'] == 'mtproto':
                        del config['outbounds'][out_index]
                        break
            else:
                for tag_index, rule_tag in enumerate(rule['inboundTag']):
                    if rule_tag == tag:
                        del rule['inboundTag'][tag_index]
                        break
            break
