code: def save_rules(
      tree, feature_names, class_names, model_file_path, learner_name
  ):
      try:
          rules = get_rules(tree, feature_names, class_names)
          fname = os.path.join(
              model_file_path, f"{learner_name}_rules.txt"
          )
          with open(fname, "w") as fout:
              for r in rules:
                  fout.write(r + "\n\n")
      except Exception as e:
          logger.info(
              f"Problem with extracting decision tree rules. {str(e)}"
          )
  
imports: import logging
  import os
  import warnings
  import numpy
  import sklearn
  from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
  from supervised.algorithms.algorithm import BaseAlgorithm
  from supervised.algorithms.registry import BINARY_CLASSIFICATION, MULTICLASS_CLASSIFICATION, REGRESSION, AlgorithmsRegistry
  from supervised.algorithms.sklearn import SklearnAlgorithm
  from supervised.utils.config import LOG_LEVEL
  import dtreeviz
  from sklearn.tree import _tree
  from supervised.utils.subsample import subsample
label_desc: Use image node_id 2 for calling a global function with example usage: save_rules(tree, feature_names, class_names, model_file_path, learner_name) without return types