class_docstr: Base class for parametric objects with tags in sktime.
  
  Extends skbase BaseObject with additional features.
class_docstr_tok: ["Base","class","for","parametric","objects","with","tags","in","sktime",".","Extends","skbase","BaseObject","with","additional","features","."]
docstr: Save serialized self to bytes-like object or to (.zip) file.
  
  Behaviour:
  if `path` is None, returns an in-memory serialized self
  if `path` is a file location, stores self at that location as a zip file
  
  saved files are zip files with following contents:
  _metadata - contains class of self, i.e., type(self)
  _obj - serialized self. This class uses the default serialization (pickle).
  
  Parameters
  ----------
  path : None or file location (str or Path)
      if None, self is saved to an in-memory object
      if file location, self is saved to that file location. If:
          path="estimator" then a zip file `estimator.zip` will be made at cwd.
          path="/home/stored/estimator" then a zip file `estimator.zip` will be
          stored in `/home/stored/`.
  
  serialization_format: str, default = "pickle"
      Module to use for serialization.
      The available options are "pickle" and "cloudpickle".
      Note that non-default formats might require
      installation of other soft dependencies.
  
  Returns
  -------
  if `path` is None - in-memory serialized self
  if `path` is file location - ZipFile with reference to the file
docstr_tok: ["Save","serialized","self","to","bytes-like","object","or","to","(",".zip",")","file",".","Behaviour",":","if","`","path","`","is","None",",","returns","an","in-memory","serialized","self","if","`","path","`","is","a","file","location",",","stores","self","at","that","location","as","a","zip","file","saved","files","are","zip","files","with","following","contents",":","_metadata","-","contains","class","of","self",",","i.e.",",","type","(","self",")","_obj","-","serialized","self",".","This","class","uses","the","default","serialization","(","pickle",")",".","Parameters","--","--","--","--","--","path",":","None","or","file","location","(","str","or","Path",")","if","None",",","self","is","saved","to","an","in-memory","object","if","file","location",",","self","is","saved","to","that","file","location",".","If",":","path=","''","estimator","''","then","a","zip","file","`","estimator.zip","`","will","be","made","at","cwd",".","path=","''","\/home\/stored\/estimator","''","then","a","zip","file","`","estimator.zip","`","will","be","stored","in","`","\/home\/stored\/","`",".","serialization_format",":","str",",","default","=","``","pickle","''","Module","to","use","for","serialization",".","The","available","options","are","``","pickle","''","and","``","cloudpickle","''",".","Note","that","non-default","formats","might","require","installation","of","other","soft","dependencies",".","Returns","--","--","--","-","if","`","path","`","is","None","-","in-memory","serialized","self","if","`","path","`","is","file","location","-","ZipFile","with","reference","to","the","file"]
code: def save(self, path=None, serialization_format="pickle"):
      """Save serialized self to bytes-like object or to (.zip) file.
  
      Behaviour:
      if `path` is None, returns an in-memory serialized self
      if `path` is a file location, stores self at that location as a zip file
  
      saved files are zip files with following contents:
      _metadata - contains class of self, i.e., type(self)
      _obj - serialized self. This class uses the default serialization (pickle).
  
      Parameters
      ----------
      path : None or file location (str or Path)
          if None, self is saved to an in-memory object
          if file location, self is saved to that file location. If:
              path="estimator" then a zip file `estimator.zip` will be made at cwd.
              path="/home/stored/estimator" then a zip file `estimator.zip` will be
              stored in `/home/stored/`.
  
      serialization_format: str, default = "pickle"
          Module to use for serialization.
          The available options are "pickle" and "cloudpickle".
          Note that non-default formats might require
          installation of other soft dependencies.
  
      Returns
      -------
      if `path` is None - in-memory serialized self
      if `path` is file location - ZipFile with reference to the file
      """
      import pickle
      import shutil
      from pathlib import Path
      from zipfile import ZipFile
  
      from sktime.utils.validation._dependencies import (
          _check_soft_dependencies,
      )
  
      if serialization_format not in SERIALIZATION_FORMATS:
          raise ValueError(
              f"The provided `serialization_format`='{serialization_format}' "
              "is not yet supported. The possible formats are: "
              f"{SERIALIZATION_FORMATS}."
          )
  
      if path is not None and not isinstance(path, (str, Path)):
          raise TypeError(
              "`path` is expected to either be a string or a Path object "
              f"but found of type:{type(path)}."
          )
      if path is not None:
          path = Path(path) if isinstance(path, str) else path
          path.mkdir()
  
      if serialization_format == "cloudpickle":
          _check_soft_dependencies("cloudpickle", severity="error")
          import cloudpickle
  
          if path is None:
              return (type(self), cloudpickle.dumps(self))
  
          with open(path / "_metadata", "wb") as file:
              cloudpickle.dump(type(self), file)
          with open(path / "_obj", "wb") as file:
              cloudpickle.dump(self, file)
  
      elif serialization_format == "pickle":
          if path is None:
              return (type(self), pickle.dumps(self))
  
          with open(path / "_metadata", "wb") as file:
              pickle.dump(type(self), file)
          with open(path / "_obj", "wb") as file:
              pickle.dump(self, file)
  
      shutil.make_archive(base_name=path, format="zip", root_dir=path)
      shutil.rmtree(path)
      return ZipFile(path.with_name(f"{path.stem}.zip"))
  
imports: import warnings
  from copy import deepcopy
  from skbase.base import BaseObject
  from sklearn import clone
  from sklearn.base import BaseEstimator
  from sktime.exceptions import NotFittedError
  from sktime.utils.random_state import set_random_state
label_desc: Use image node_id 4 for calling the BaseObject obj's underlying member method code with example usage: obj.save(path, serialization_format) and returns: ZipFile, type,  cloudpickle, type,  pickle