def set_default_dataset_from_list_serialize_method(new):
    """
    Context manager for using custom serialize function when creating DatasetFromList
    """

    global _DEFAULT_DATASET_FROM_LIST_SERIALIZE_METHOD
    orig = _DEFAULT_DATASET_FROM_LIST_SERIALIZE_METHOD
    _DEFAULT_DATASET_FROM_LIST_SERIALIZE_METHOD = new
    yield
    _DEFAULT_DATASET_FROM_LIST_SERIALIZE_METHOD = orig

    Context manager for using custom serialize function when creating DatasetFromList
    
ControlNet-v1-1-nightly/annotator/oneformer/detectron2/data/common.py