code: def check_query_instance_validity(
      self,
      features_to_vary,
      permitted_range,
      query_instance,
      feature_ranges_orig,
  ):
      for feature in query_instance:
          if feature == self.data_interface.outcome_name:
              raise ValueError(
                  "Target",
                  self.data_interface.outcome_name,
                  "present in query instance",
              )
  
          if feature not in self.data_interface.feature_names:
              raise ValueError(
                  "Feature", feature, "not present in training data!"
              )
      for feature in self.data_interface.categorical_feature_names:
          if (
              query_instance[feature].values[0]
              not in feature_ranges_orig[feature]
              and str(query_instance[feature].values[0])
              not in feature_ranges_orig[feature]
          ):
              raise ValueError(
                  "Feature", feature, "has a value outside the dataset."
              )
  
          if (
              feature not in features_to_vary
              and permitted_range is not None
          ):
              if (
                  feature in permitted_range
                  and feature
                  in self.data_interface.continuous_feature_names
              ):
                  if (
                      not permitted_range[feature][0]
                      <= query_instance[feature].values[0]
                      <= permitted_range[feature][1]
                  ):
                      raise ValueError(
                          "Feature:",
                          feature,
                          "is outside the permitted range and isn't allowed to vary.",
                      )
              elif (
                  feature in permitted_range
                  and feature
                  in self.data_interface.categorical_feature_names
              ):
                  if (
                      query_instance[feature].values[0]
                      not in self.feature_range[feature]
                  ):
                      raise ValueError(
                          "Feature:",
                          feature,
                          "is outside the permitted range and isn't allowed to vary.",
                      )
  
imports: import pickle
  from abc import ABC, abstractmethod
  from collections.abc import Iterable
  from typing import Any, List
  import numpy
  import pandas
  from raiutils.exceptions import UserConfigValidationException
  from sklearn.neighbors import KDTree
  from tqdm import tqdm
  from dice_ml.constants import ModelTypes, _PostHocSparsityTypes
  from dice_ml.counterfactual_explanations import CounterfactualExplanations
label_desc: Use image node_id 7 for calling the ExplainerBase obj's underlying member method code with example usage: obj.check_query_instance_validity(features_to_vary, permitted_range, query_instance, feature_ranges_orig) without return types