code: def test_invalid_query_instance(
      self,
      desired_range,
      desired_class,
      sample_custom_vars_query_1,
      total_CFs,
      features_to_vary,
      permitted_range,
  ):
      (
          self.exp.dataset_with_predictions,
          self.exp.KD_tree,
          self.exp.predictions,
      ) = self.exp.build_KD_tree(
          self.data_df_copy,
          desired_range,
          desired_class,
          self.exp.predicted_outcome_name,
      )
  
      with pytest.raises(
          ValueError,
          match="is outside the permitted range and isn't allowed to vary",
      ):
          self.exp._generate_counterfactuals(
              query_instance=sample_custom_vars_query_1,
              total_CFs=total_CFs,
              features_to_vary=features_to_vary,
              permitted_range=permitted_range,
          )
  
imports: import numpy
  import pytest
  from dice_ml.counterfactual_explanations import CounterfactualExplanations
  from dice_ml.diverse_counterfactuals import CounterfactualExamples
label_desc: Use image node_id 2 for calling the TestDiceKDBinaryVarsClassificationMethods obj's underlying member method code with example usage: obj.test_invalid_query_instance(desired_range, desired_class, sample_custom_vars_query_1, total_CFs, features_to_vary, permitted_range) without return types