<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save(obj, path=None, name=None, sep=_sep, deep=False, mode='npz', strip=None, compressed=False, verb=True, return_pfe=False):
 """ Save the ToFu object ToFu provides built-in saving and loading functions for ToFu objects. Specifying saving path ad name is optional (defaults recommended) The mode refers to the file format Good practices are: - save all struct objects Parameters obj : ToFuObject subclass instance The object to be saved path : None / str The folder where to save, if None (recommended), uses obj.Id.SavePath name : None / str The file name, if None (recommended), uses obj.Id.SaveName mode : str Flag specifying the saving mode - 'npz': numpy file - 'mat': matlab file strip: int Flag indicating how stripped the saved object should be See docstring of self.strip() deep: bool Flag, used when the object has other tofu objects as attributes Indicated whether these attribute object should be: - True: converted to dict themselves in order to be saved inside the same file as attributes (-> uses self.to_dict(deep='dict')) - False: not converted, in that the strategy would be to save them separately and store only the reference to the saved files instead of the objects themselves. To do this, you must: 1/ Save all object attributes independently 2/ Store only the reference by doing self.strip(-1) The strip() method will check they have been saved before removing them, and throw an Exception otherwise 3/ self.save(deep=False) compressed : bool Flag indicating whether to compress the file (slower, not recommended) verb : bool Flag indicating whether to print a summary (recommended) """

    msg = "Arg obj must be a tofu subclass instance !"
    assert issubclass(obj.__class__, ToFuObject), msg
    msg = "Arg path must be None or a str (folder) !"
    assert path is None or isinstance(path,str), msg
    msg = "Arg name must be None or a str (file name) !"
    assert name is None or isinstance(name,str), msg
    msg = "Arg mode must be in ['npz','mat'] !"
    assert mode in ['npz','mat'], msg
    msg = "Arg compressed must be a bool !"
    assert type(compressed) is bool, msg
    msg = "Arg verb must be a bool !"
    assert type(verb) is bool, msg

    # Check path, name, mode
    path, name, mode = get_pathfileext(path=path, name=name,
                                       path_def=obj.Id.SavePath,
                                       name_def=obj.Id.SaveName, mode=mode)

    # Update self._Id fields
    obj._Id._SavePath = path
    if name!=obj.Id.SaveName:
        obj._Id.set_SaveName(name)

    # Get stripped dictionnary
    deep = 'dict' if deep else 'ref'
    dd = obj.to_dict(strip=strip, sep=sep, deep=deep)

    pathfileext = os.path.join(path,name+'.'+mode)

    if mode=='npz':
        _save_npz(dd, pathfileext, compressed=compressed)
    elif mode=='mat':
        _save_mat(dd, pathfileext, compressed=compressed)

    # print
    if verb:
        msg = "Saved in :\n"
        msg += "    "+pathfileext
        print(msg)
    if return_pfe:
        return pathfileext