def convert_weights(weight):
    """Weight Converter.

    Converts the weights from timm to mmpretrain
    Args:
        weight (dict): weight dict from timm
    Returns:
        Converted weight dict for mmpretrain
    """
    result = dict()
    result['meta'] = dict()
    temp = dict()
    mapping = {
        'dwconv': 'depthwise_conv',
        'pwconv1': 'pointwise_conv1',
        'pwconv2': 'pointwise_conv2',
        'xca': 'csa',
        'convs': 'conv_modules',
        'token_projection': 'proj',
        'pos_embd': 'pos_embed',
        'temperature': 'scale',
    }
    strict_mapping = {
        'norm.weight': 'norm3.weight',
        'norm.bias': 'norm3.bias',
    }

    try:
        weight = weight['model_ema']
    except KeyError:
        weight = weight['state_dict']  # for model learned with usi
    else:
        raise NotImplementedError

    for k, v in weight.items():
        # keyword mapping
        for mk, mv in mapping.items():
            if mk in k:
                k = k.replace(mk, mv)
        # strict mapping
        for mk, mv in strict_mapping.items():
            if mk == k:
                k = mv

        if k.startswith('head.'):
            temp['head.fc.' + k[5:]] = v
        else:
            temp['backbone.' + k] = v

    result['state_dict'] = temp
    return result
Weight Converter.

    Converts the weights from timm to mmpretrain
    Args:
        weight (dict): weight dict from timm
    Returns:
        Converted weight dict for mmpretrain
    
tools/model_converters/edgenext_to_mmpretrain.py