def _load_state_dict_pre_hook(self, state_dict, prefix, local_meta, *args,
                                  **kwargs):
        """A hook function to convert old-version state dict of
        :class:`DEKRHead` (before MMPose v1.0.0) to a compatible format
        of :class:`DEKRHead`.

        The hook will be automatically registered during initialization.
        """
        version = local_meta.get('version', None)
        if version and version >= self._version:
            return

        # convert old-version state dict
        keys = list(state_dict.keys())
        for k in keys:
            if 'offset_conv_layer' in k:
                v = state_dict.pop(k)
                k = k.replace('offset_conv_layers', 'displacement_conv_layers')
                if 'displacement_conv_layers.3.' in k:
                    # the source and target of displacement vectors are
                    # opposite between two versions.
                    v = -v
                state_dict[k] = v

            if 'heatmap_conv_layers.2' in k:
                # root heatmap is at the first/last channel of the
                # heatmap tensor in MMPose v0.x/1.x, respectively.
                v = state_dict.pop(k)
                state_dict[k] = torch.cat((v[1:], v[:1]))

            if 'rescore_net' in k:
                v = state_dict.pop(k)
                k = k.replace('rescore_net', 'head.rescore_net')
                state_dict[k] = v
A hook function to convert old-version state dict of
        :class:`DEKRHead` (before MMPose v1.0.0) to a compatible format
        of :class:`DEKRHead`.

        The hook will be automatically registered during initialization.
        
mmpose/mmpose/models/heads/hybrid_heads/dekr_head.py