class_docstr: Mixin that provides save and load functionalities.
class_docstr_tok: ["Mixin","that","provides","save","and","load","functionalities","."]
code: def __save(self, dirname, ancestors):
      os.makedirs(dirname, exist_ok=True)
      ancestors.append(self)
      for attr in self.saved_attributes:
          assert hasattr(self, attr)
          attr_value = getattr(self, attr)
          if attr_value is None:
              continue
          if isinstance(attr_value, AttributeSavingMixin):
              assert not any(
                  attr_value is ancestor for ancestor in ancestors
              ), "Avoid an infinite loop"
              attr_value.__save(os.path.join(dirname, attr), ancestors)
          else:
              serializers.save_npz(
                  os.path.join(dirname, "{}.npz".format(attr)),
                  getattr(self, attr),
              )
      ancestors.pop()
  
imports: from abc import ABCMeta
  from abc import abstractmethod
  from abc import abstractproperty
  import os
  from chainer import serializers
  import numpy
  import warnings
label_desc: Use image node_id 3 for calling the AttributeSavingMixin obj's underlying member method code with example usage: obj.__save(dirname, ancestors) without return types