code: def save(self, upload=False):
      if self.fitting is None:
          raise ValueError(
              "This model has not been fit yet. There is no point in saving."
          )
  
      if not os.path.exists(self.fitting_path()):
          try:
              os.makedirs(self.fitting_path())
          except FileExistsError as ex:
              pass  # race to create
  
      with timer("pickle model"):
          with open(self.model_path(), "wb") as f:
              pickle.dump(self, f)
  
      with open(join(self.fitting_path(), "params.json"), "w") as f:
          params = {}
          for child in [self.estimator, self.pipeline]:
              param = child.__module__ + "." + child.__class__.__name__
              params[param] = {}
              if hasattr(child, "__getstate__"):
                  state = child.__getstate__()
              else:
                  state = child.__dict__
              for key, value in state.items():
                  if not key.startswith("_"):
                      params[param][key] = value.__repr__()
          json.dump(params, f, indent=2, sort_keys=True)
  
      if self.stats:
          with open(join(self.fitting_path(), "stats.json"), "w") as f:
              json.dump(self.stats, f, indent=2, sort_keys=True)
  
      if upload:
          url = self.upload()
          self.fitting.url = url
          self.fitting.uploaded_at = datetime.datetime.utcnow()
          self.fitting.save()
  
imports: from __future__ import absolute_import
  import datetime
  import json
  import logging
  import os.path
  from os.path import join
  import pickle
  import inspect
  import warnings
  import botocore
  import lore.ansi
  import lore.estimators
  import lore.metadata
  from lore.env import require
  from lore.util import timer, timed, before_after_callbacks, convert_df_columns_to_json
  import shap
  from tabulate import tabulate
  from sklearn.model_selection import RandomizedSearchCV
label_desc: Use image node_id 23 for calling the Base obj's underlying member method code with example usage: obj.save(upload) without return types