I have a class that holds many nn.Modules and several pieces of data that aren’t modules as well: e.g.
class MyClass(object):
    def __init__(self):
        self._module1 = ...
        self._module2 = ...
        self._not_a_module1 = ...
        self._not_a_module1 = ...

I’d like to save and restore all of the data held by the class. Is it safe for me to directly pickle the class? e.g.
import pickle

c = MyClass()
with open("saved.txt", "w") as f:
    pickle.dump(c, f)

# ... later
with open("saved.txt", "r") as f:
    c = pickle.load(f)

Or is it necessary for me to call torch.save on the modules and separately save the non-module data on my own?
Related question: is directly pickling nn.Modules safe to do? Or do I have to save them using torch.save?