def is_persistent(obj):
    r"""Test whether the given object or class is persistent, i.e.,
    whether it will save its source code when pickled.
    """
    try:
        if obj in _decorators:
            return True
    except TypeError:
        pass
    return type(obj) in _decorators # pylint: disable=unidiomatic-typecheck
Test whether the given object or class is persistent, i.e.,
    whether it will save its source code when pickled.
    
torch_utils/persistence.py