docstr: Compare 2 ML Params instances for the given param, and assert both have the same param value
  and parent. The param must be a parameter of m1.
code: def _compare_params(self, m1, m2, param):
      """
      Compare 2 ML Params instances for the given param, and assert both have the same param value
      and parent. The param must be a parameter of m1.
      """
      # Prevent key not found error in case of some param in neither paramMap nor defaultParamMap.
      if m1.isDefined(param):
          paramValue1 = m1.getOrDefault(param)
          paramValue2 = m2.getOrDefault(m2.getParam(param.name))
          if isinstance(paramValue1, Params):
              self._compare_pipelines(paramValue1, paramValue2)
          else:
              self.assertEqual(
                  paramValue1, paramValue2
              )  # for general types param
          # Assert parents are equal
          self.assertEqual(param.parent, m2.getParam(param.name).parent)
      else:
          # If m1 is not defined param, then m2 should not, too. See SPARK-14931.
          self.assertFalse(m2.isDefined(m2.getParam(param.name)))
  
imports: import json
  from shutil import rmtree
  import tempfile
  import unittest
  from pyspark.ml import Transformer
  from pyspark.ml.classification import DecisionTreeClassifier, FMClassifier, FMClassificationModel, LogisticRegression, MultilayerPerceptronClassifier, MultilayerPerceptronClassificationModel, OneVsRest, OneVsRestModel
  from pyspark.ml.clustering import KMeans
  from pyspark.ml.feature import Binarizer, Bucketizer, HashingTF, PCA
  from pyspark.ml.linalg import Vectors
  from pyspark.ml.param import Params
  from pyspark.ml.pipeline import Pipeline, PipelineModel
  from pyspark.ml.regression import DecisionTreeRegressor, GeneralizedLinearRegression, GeneralizedLinearRegressionModel, LinearRegression
  from pyspark.ml.util import DefaultParamsReadable, DefaultParamsWriter
  from pyspark.ml.wrapper import JavaParams
  from pyspark.testing.mlutils import MockUnaryTransformer, SparkSessionTestCase
label_desc: Use image node_id 6 for calling the PersistenceTest obj's underlying member method code with example usage: obj._compare_params(m1, m2, param) without return types