code: def _structure_rename_fields_hook(
      data: t.Dict[str, t.Any], cl: t.Type[_T]
  ) -> _T:
      # pop is atomic, so we don't need to worry about performance deficit.
      # See https://stackoverflow.com/a/17326099/8643197.
      rev = {
          k: data.pop(v)
          for k, v in getattr(cl, "__rename_fields__").items()
          if v in data
      }
      return cl(**rev, **data)
  
imports: from __future__ import annotations
  import logging
  import typing
  import attr
  import cattr.errors
  import yaml
  from cattr.gen import make_dict_unstructure_fn
  from cattr.gen import override
  from ...utils import bentoml_cattr
label_desc: Use image node_id 1 for calling a global function with example usage: _structure_rename_fields_hook(data, cl) and returns: cl