code: def constraints(cls=None, classification_type=None):
      """Restricts a query strategy to certain settings such as single- or multi-label classification
  
      This should be used sparingly and mostly in cases where a misconfiguration would not raise
      an error but is clearly unwanted.
      """
      if not callable(cls):
          return partial(
              constraints, classification_type=classification_type
          )
  
      @wraps(cls, updated=())
      class QueryStrategyConstraints(cls):
          def query(
              self,
              clf,
              datasets,
              indices_unlabeled,
              indices_labeled,
              y,
              *args,
              n=10,
              **kwargs,
          ):
              if classification_type is not None:
                  if isinstance(classification_type, str):
                      classification_type_ = (
                          ClassificationType.from_str(
                              classification_type
                          )
                      )
  
                  if (
                      classification_type_
                      == ClassificationType.SINGLE_LABEL
                      and isinstance(y, csr_matrix)
                  ):
                      raise RuntimeError(
                          f"Invalid configuration: This query strategy requires "
                          f"classification_type={str(classification_type_.value)} "
                          f"but multi-label data was encountered"
                      )
                  elif (
                      classification_type_
                      == ClassificationType.MULTI_LABEL
                      and not isinstance(y, csr_matrix)
                  ):
                      raise RuntimeError(
                          f"Invalid configuration: This query strategy requires "
                          f"classification_type={str(classification_type_.value)} "
                          f"but single-label data was encountered"
                      )
  
              return super().query(
                  clf,
                  datasets,
                  indices_unlabeled,
                  indices_labeled,
                  y,
                  *args,
                  n=n,
                  **kwargs,
              )
  
      return QueryStrategyConstraints
  
imports: from enum import Enum
  from functools import partial, wraps
  from scipy.sparse import csr_matrix
label_desc: Use image node_id 1 for calling a global function with example usage: constraints(cls, classification_type) and returns: QueryStrategyConstraints, partial, super