def _try_get_key(cfg, *keys, default=None):
    """
    Try select keys from cfg until the first key that exists. Otherwise return default.
    """
    if isinstance(cfg, CfgNode):
        cfg = OmegaConf.create(cfg.dump())
    for k in keys:
        none = object()
        p = OmegaConf.select(cfg, k, default=none)
        if p is not none:
            return p
    return default

    Try select keys from cfg until the first key that exists. Otherwise return default.
    
iGPT/models/grit_src/third_party/CenterNet2/detectron2/engine/defaults.py