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 = {
        'c.weight': 'conv2d.weight',
        'bn.weight': 'bn2d.weight',
        'bn.bias': 'bn2d.bias',
        'bn.running_mean': 'bn2d.running_mean',
        'bn.running_var': 'bn2d.running_var',
        'bn.num_batches_tracked': 'bn2d.num_batches_tracked',
        'layers': 'stages',
        'norm_head': 'norm3',
    }

    weight = weight['model']

    for k, v in weight.items():
        # keyword mapping
        for mk, mv in mapping.items():
            if mk in k:
                k = k.replace(mk, 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/tinyvit_to_mmpretrain.py