class_docstr: Base class for contexts.
class_docstr_tok: ["Base","class","for","contexts","."]
docstr: Assert task_type matching given types.
  
  If task_type is defined, validate it and raise error if needed, else returns True.
  If task_type is not defined, return False.
docstr_tok: ["Assert","task_type","matching","given","types",".","If","task_type","is","defined",",","validate","it","and","raise","error","if","needed",",","else","returns","True",".","If","task_type","is","not","defined",",","return","False","."]
code: def assert_task_type(self, *expected_types):
      """Assert task_type matching given types.
  
      If task_type is defined, validate it and raise error if needed, else returns True.
      If task_type is not defined, return False.
      """
      if self.task_type not in expected_types:
          raise ModelValidationError(
              f"Check is relevant for models of type {[e.value.lower() for e in expected_types]}, "
              f"but received model of type '{self.task_type.value.lower()}'"  # pylint: disable=inconsistent-quotes
          )
      return True
  
file_path: deepchecks/deepchecks/core/context.py
imports: from abc import ABC, abstractmethod
  from deepchecks.core import CheckFailure, CheckResult, DatasetKind
  from deepchecks.core.errors import DeepchecksNotSupportedError, DeepchecksValueError, ModelValidationError
label_desc: Use image node_id 4 for calling the BaseContext obj's underlying member method code with example usage: obj.assert_task_type() and returns: True