code: def _interact_with_folder(self, output_folder, action):
          
          if not action in ('r', 'w'):
              raise ValueError("action must be either 'r' or 'w'.")
          for key, item in self.__dict__.items():
              if isinstance(item, dict):
                  for side in ("left", "right"):
                      filename = os.path.join(output_folder,
                                              "{}_{}.npy".format(key, side))
                      if action == 'w':
                          np.save(filename, self.__dict__[key][side])
                      else:
                          self.__dict__[key][side] = np.load(filename)
              else:
                  filename = os.path.join(output_folder, "{}.npy".format(key))
                  if action == 'w':
                      np.save(filename, self.__dict__[key])
                  else:
                      self.__dict__[key] = np.load(filename)
docs: Export/import matrices as *.npy files to/from an output folder.
  
          ``action`` is a string. It determines whether the method reads or writes
          to disk. It must have one of the following values: ('r', 'w').