code: def test_desired_class(
      self,
      desired_class,
      method,
      sample_custom_query_2,
      custom_public_data_interface,
      sklearn_binary_classification_model_interface,
  ):
      exp = dice_ml.Dice(
          custom_public_data_interface,
          sklearn_binary_classification_model_interface,
          method=method,
      )
      ans = exp.generate_counterfactuals(
          query_instances=sample_custom_query_2,
          features_to_vary="all",
          total_CFs=2,
          desired_class=desired_class,
          proximity_weight=0.2,
          sparsity_weight=0.2,
          diversity_weight=5.0,
          categorical_penalty=0.1,
          permitted_range=None,
      )
      if method != "kdtree":
          assert all(
              ans.cf_examples_list[0]
              .final_cfs_df[exp.data_interface.outcome_name]
              .values
              == [desired_class] * 2
          )
      else:
          assert all(
              ans.cf_examples_list[0]
              .final_cfs_df_sparse[exp.data_interface.outcome_name]
              .values
              == [desired_class] * 2
          )
  
      exp.serialize_explainer(method + ".pkl")
      new_exp = ExplainerBase.deserialize_explainer(method + ".pkl")
  
      ans = new_exp.generate_counterfactuals(
          query_instances=sample_custom_query_2,
          features_to_vary="all",
          total_CFs=2,
          desired_class=desired_class,
          proximity_weight=0.2,
          sparsity_weight=0.2,
          diversity_weight=5.0,
          categorical_penalty=0.1,
          permitted_range=None,
      )
      if method != "kdtree":
          assert all(
              ans.cf_examples_list[0]
              .final_cfs_df[new_exp.data_interface.outcome_name]
              .values
              == [desired_class] * 2
          )
      else:
          assert all(
              ans.cf_examples_list[0]
              .final_cfs_df_sparse[new_exp.data_interface.outcome_name]
              .values
              == [desired_class] * 2
          )
  
imports: import re
  import numpy
  import pandas
  import pytest
  from rai_test_utils.datasets.tabular import create_housing_data
  from raiutils.exceptions import UserConfigValidationException
  from sklearn.ensemble import RandomForestRegressor
  import dice_ml
  from dice_ml.diverse_counterfactuals import CounterfactualExamples
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
  from dice_ml.utils import helpers
  from ..conftest import _load_custom_testing_binary_model
label_desc: Use image node_id 12 for calling the TestExplainerBaseBinaryClassification obj's underlying member method code with example usage: obj.test_desired_class(desired_class, method, sample_custom_query_2, custom_public_data_interface, sklearn_binary_classification_model_interface) without return types