We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG][CV] deepchecks should either validate model.eval status or actively create it 
**Describe the bug**
Checks can crash or give wrong results if models are set by mistake to training mode. 

**To Reproduce**
Run metrics check with model.train() preceding it.

**Expected behavior**
Either we validate that the model is in the correct state, or we actively call model.eval()


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `deepchecks/vision/context.py`
Content:
```
1 # ----------------------------------------------------------------------------
2 # Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
3 #
4 # This file is part of Deepchecks.
5 # Deepchecks is distributed under the terms of the GNU Affero General
6 # Public License (version 3 or later).
7 # You should have received a copy of the GNU Affero General Public License
8 # along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
9 # ----------------------------------------------------------------------------
10 #
11 """Module for base vision context."""
12 import logging
13 from typing import Mapping, Union, Iterable, Any, Tuple
14 
15 import torch
16 from torch import nn
17 from ignite.metrics import Metric
18 
19 from deepchecks.core import DatasetKind
20 from deepchecks.vision.vision_data import VisionData, TaskType
21 from deepchecks.vision.utils.validation import apply_to_tensor
22 from deepchecks.core.errors import (
23     DatasetValidationError, DeepchecksNotImplementedError, ModelValidationError,
24     DeepchecksNotSupportedError, DeepchecksValueError
25 )
26 
27 
28 __all__ = ['Context']
29 
30 
31 logger = logging.getLogger('deepchecks')
32 
33 
34 class Batch:
35     """Represents dataset batch returned by the dataloader during iteration."""
36 
37     def __init__(
38         self,
39         batch: Tuple[Iterable[Any], Iterable[Any]],
40         context: 'Context',
41         dataset_kind: DatasetKind
42     ):
43         self._context = context
44         self._dataset_kind = dataset_kind
45         self._batch = apply_to_tensor(batch, lambda it: it.to(self._context.device))
46         self._labels = None
47         self._predictions = None
48         self._images = None
49 
50     @property
51     def labels(self):
52         if self._labels is None:
53             dataset = self._context.get_data_by_kind(self._dataset_kind)
54             self._labels = dataset.batch_to_labels(self._batch)
55         return self._labels
56 
57     @property
58     def predictions(self):
59         if self._predictions is None:
60             dataset = self._context.get_data_by_kind(self._dataset_kind)
61             self._predictions = dataset.infer_on_batch(self._batch, self._context.model, self._context.device)
62         return self._predictions
63 
64     @property
65     def images(self):
66         if self._images is None:
67             dataset = self._context.get_data_by_kind(self._dataset_kind)
68             self._images = dataset.batch_to_images(self._batch)
69         return self._images
70 
71     def __getitem__(self, index):
72         return self._batch[index]
73 
74 
75 class Context:
76     """Contains all the data + properties the user has passed to a check/suite, and validates it seamlessly.
77 
78     Parameters
79     ----------
80     train : VisionData , default: None
81         Dataset or DataFrame object, representing data an estimator was fitted on
82     test : VisionData , default: None
83         Dataset or DataFrame object, representing data an estimator predicts on
84     model : BasicModel , default: None
85         A scikit-learn-compatible fitted estimator instance
86     model_name: str , default: ''
87         The name of the model
88     scorers : Mapping[str, Metric] , default: None
89         dict of scorers names to a Metric
90     scorers_per_class : Mapping[str, Metric] , default: None
91         dict of scorers for classification without averaging of the classes.
92         See <a href=
93         "https://scikit-learn.org/stable/modules/model_evaluation.html#from-binary-to-multiclass-and-multilabel">
94         scikit-learn docs</a>
95     device : Union[str, torch.device], default: 'cpu'
96         processing unit for use
97     random_state : int
98         A seed to set for pseudo-random functions
99     n_samples : int, default: None
100     """
101 
102     def __init__(self,
103                  train: VisionData = None,
104                  test: VisionData = None,
105                  model: nn.Module = None,
106                  model_name: str = '',
107                  scorers: Mapping[str, Metric] = None,
108                  scorers_per_class: Mapping[str, Metric] = None,
109                  device: Union[str, torch.device, None] = 'cpu',
110                  random_state: int = 42,
111                  n_samples: int = None
112                  ):
113         # Validations
114         if train is None and test is None and model is None:
115             raise DeepchecksValueError('At least one dataset (or model) must be passed to the method!')
116         if test and not train:
117             raise DatasetValidationError('Can\'t initialize context with only test. if you have single dataset, '
118                                          'initialize it as train')
119         if train and test:
120             train.validate_shared_label(test)
121 
122         self._device = torch.device(device) if isinstance(device, str) else (device if device else torch.device('cpu'))
123 
124         if model is not None:
125             for dataset, dataset_type in zip([train, test], ['train', 'test']):
126                 if dataset is not None:
127                     try:
128                         dataset.validate_prediction(next(iter(dataset.data_loader)), model, self._device)
129                     except DeepchecksNotImplementedError:
130                         logger.warning('validate_prediction() was not implemented in %s dataset, '
131                                        'some checks will not run', dataset_type)
132 
133         # The copy does 2 things: Sample n_samples if parameter exists, and shuffle the data.
134         # we shuffle because the data in VisionData is set to be sampled in a fixed order (in the init), so if the user
135         # wants to run without random_state we need to forcefully shuffle (to have different results on different runs
136         # from the same VisionData object), and if there is a random_state the shuffle will always have same result
137         if train:
138             train = train.copy(shuffle=True, n_samples=n_samples, random_state=random_state)
139         if test:
140             test = test.copy(shuffle=True, n_samples=n_samples, random_state=random_state)
141 
142         self._train = train
143         self._test = test
144         self._model = model
145         self._user_scorers = scorers
146         self._user_scorers_per_class = scorers_per_class
147         self._model_name = model_name
148         self.random_state = random_state
149 
150     # Properties
151     # Validations note: We know train & test fit each other so all validations can be run only on train
152 
153     @property
154     def train(self) -> VisionData:
155         """Return train if exists, otherwise raise error."""
156         if self._train is None:
157             raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without train dataset')
158         return self._train
159 
160     @property
161     def test(self) -> VisionData:
162         """Return test if exists, otherwise raise error."""
163         if self._test is None:
164             raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without test dataset')
165         return self._test
166 
167     @property
168     def model(self) -> nn.Module:
169         """Return & validate model if model exists, otherwise raise error."""
170         if self._model is None:
171             raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without model')
172         return self._model
173 
174     @property
175     def model_name(self):
176         """Return model name."""
177         return self._model_name
178 
179     @property
180     def device(self) -> torch.device:
181         """Return device specified by the user."""
182         return self._device
183 
184     def have_test(self):
185         """Return whether there is test dataset defined."""
186         return self._test is not None
187 
188     def assert_task_type(self, *expected_types: TaskType):
189         """Assert task_type matching given types."""
190         if self.train.task_type not in expected_types:
191             raise ModelValidationError(
192                 f'Check is irrelevant for task of type {self.train.task_type}')
193         return True
194 
195     def get_data_by_kind(self, kind: DatasetKind):
196         """Return the relevant VisionData by given kind."""
197         if kind == DatasetKind.TRAIN:
198             return self.train
199         elif kind == DatasetKind.TEST:
200             return self.test
201         else:
202             raise DeepchecksValueError(f'Unexpected dataset kind {kind}')
203
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/deepchecks/vision/context.py b/deepchecks/vision/context.py
--- a/deepchecks/vision/context.py
+++ b/deepchecks/vision/context.py
@@ -122,6 +122,13 @@
         self._device = torch.device(device) if isinstance(device, str) else (device if device else torch.device('cpu'))
 
         if model is not None:
+            if not isinstance(model, nn.Module):
+                logger.warning('Model is not a torch.nn.Module. Deepchecks can\'t validate that model is in '
+                               'evaluation state.')
+            else:
+                if model.training:
+                    raise DatasetValidationError('Model is not in evaluation state. Please set model training '
+                                                 'parameter to False or run model.eval() before passing it.')
             for dataset, dataset_type in zip([train, test], ['train', 'test']):
                 if dataset is not None:
                     try:

{"golden_diff": "diff --git a/deepchecks/vision/context.py b/deepchecks/vision/context.py\n--- a/deepchecks/vision/context.py\n+++ b/deepchecks/vision/context.py\n@@ -122,6 +122,13 @@\n         self._device = torch.device(device) if isinstance(device, str) else (device if device else torch.device('cpu'))\n \n         if model is not None:\n+            if not isinstance(model, nn.Module):\n+                logger.warning('Model is not a torch.nn.Module. Deepchecks can\\'t validate that model is in '\n+                               'evaluation state.')\n+            else:\n+                if model.training:\n+                    raise DatasetValidationError('Model is not in evaluation state. Please set model training '\n+                                                 'parameter to False or run model.eval() before passing it.')\n             for dataset, dataset_type in zip([train, test], ['train', 'test']):\n                 if dataset is not None:\n                     try:\n", "issue": "[BUG][CV] deepchecks should either validate model.eval status or actively create it \n**Describe the bug**\r\nChecks can crash or give wrong results if models are set by mistake to training mode. \r\n\r\n**To Reproduce**\r\nRun metrics check with model.train() preceding it.\r\n\r\n**Expected behavior**\r\nEither we validate that the model is in the correct state, or we actively call model.eval()\r\n\n", "before_files": [{"content": "# ----------------------------------------------------------------------------\n# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)\n#\n# This file is part of Deepchecks.\n# Deepchecks is distributed under the terms of the GNU Affero General\n# Public License (version 3 or later).\n# You should have received a copy of the GNU Affero General Public License\n# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.\n# ----------------------------------------------------------------------------\n#\n\"\"\"Module for base vision context.\"\"\"\nimport logging\nfrom typing import Mapping, Union, Iterable, Any, Tuple\n\nimport torch\nfrom torch import nn\nfrom ignite.metrics import Metric\n\nfrom deepchecks.core import DatasetKind\nfrom deepchecks.vision.vision_data import VisionData, TaskType\nfrom deepchecks.vision.utils.validation import apply_to_tensor\nfrom deepchecks.core.errors import (\n    DatasetValidationError, DeepchecksNotImplementedError, ModelValidationError,\n    DeepchecksNotSupportedError, DeepchecksValueError\n)\n\n\n__all__ = ['Context']\n\n\nlogger = logging.getLogger('deepchecks')\n\n\nclass Batch:\n    \"\"\"Represents dataset batch returned by the dataloader during iteration.\"\"\"\n\n    def __init__(\n        self,\n        batch: Tuple[Iterable[Any], Iterable[Any]],\n        context: 'Context',\n        dataset_kind: DatasetKind\n    ):\n        self._context = context\n        self._dataset_kind = dataset_kind\n        self._batch = apply_to_tensor(batch, lambda it: it.to(self._context.device))\n        self._labels = None\n        self._predictions = None\n        self._images = None\n\n    @property\n    def labels(self):\n        if self._labels is None:\n            dataset = self._context.get_data_by_kind(self._dataset_kind)\n            self._labels = dataset.batch_to_labels(self._batch)\n        return self._labels\n\n    @property\n    def predictions(self):\n        if self._predictions is None:\n            dataset = self._context.get_data_by_kind(self._dataset_kind)\n            self._predictions = dataset.infer_on_batch(self._batch, self._context.model, self._context.device)\n        return self._predictions\n\n    @property\n    def images(self):\n        if self._images is None:\n            dataset = self._context.get_data_by_kind(self._dataset_kind)\n            self._images = dataset.batch_to_images(self._batch)\n        return self._images\n\n    def __getitem__(self, index):\n        return self._batch[index]\n\n\nclass Context:\n    \"\"\"Contains all the data + properties the user has passed to a check/suite, and validates it seamlessly.\n\n    Parameters\n    ----------\n    train : VisionData , default: None\n        Dataset or DataFrame object, representing data an estimator was fitted on\n    test : VisionData , default: None\n        Dataset or DataFrame object, representing data an estimator predicts on\n    model : BasicModel , default: None\n        A scikit-learn-compatible fitted estimator instance\n    model_name: str , default: ''\n        The name of the model\n    scorers : Mapping[str, Metric] , default: None\n        dict of scorers names to a Metric\n    scorers_per_class : Mapping[str, Metric] , default: None\n        dict of scorers for classification without averaging of the classes.\n        See <a href=\n        \"https://scikit-learn.org/stable/modules/model_evaluation.html#from-binary-to-multiclass-and-multilabel\">\n        scikit-learn docs</a>\n    device : Union[str, torch.device], default: 'cpu'\n        processing unit for use\n    random_state : int\n        A seed to set for pseudo-random functions\n    n_samples : int, default: None\n    \"\"\"\n\n    def __init__(self,\n                 train: VisionData = None,\n                 test: VisionData = None,\n                 model: nn.Module = None,\n                 model_name: str = '',\n                 scorers: Mapping[str, Metric] = None,\n                 scorers_per_class: Mapping[str, Metric] = None,\n                 device: Union[str, torch.device, None] = 'cpu',\n                 random_state: int = 42,\n                 n_samples: int = None\n                 ):\n        # Validations\n        if train is None and test is None and model is None:\n            raise DeepchecksValueError('At least one dataset (or model) must be passed to the method!')\n        if test and not train:\n            raise DatasetValidationError('Can\\'t initialize context with only test. if you have single dataset, '\n                                         'initialize it as train')\n        if train and test:\n            train.validate_shared_label(test)\n\n        self._device = torch.device(device) if isinstance(device, str) else (device if device else torch.device('cpu'))\n\n        if model is not None:\n            for dataset, dataset_type in zip([train, test], ['train', 'test']):\n                if dataset is not None:\n                    try:\n                        dataset.validate_prediction(next(iter(dataset.data_loader)), model, self._device)\n                    except DeepchecksNotImplementedError:\n                        logger.warning('validate_prediction() was not implemented in %s dataset, '\n                                       'some checks will not run', dataset_type)\n\n        # The copy does 2 things: Sample n_samples if parameter exists, and shuffle the data.\n        # we shuffle because the data in VisionData is set to be sampled in a fixed order (in the init), so if the user\n        # wants to run without random_state we need to forcefully shuffle (to have different results on different runs\n        # from the same VisionData object), and if there is a random_state the shuffle will always have same result\n        if train:\n            train = train.copy(shuffle=True, n_samples=n_samples, random_state=random_state)\n        if test:\n            test = test.copy(shuffle=True, n_samples=n_samples, random_state=random_state)\n\n        self._train = train\n        self._test = test\n        self._model = model\n        self._user_scorers = scorers\n        self._user_scorers_per_class = scorers_per_class\n        self._model_name = model_name\n        self.random_state = random_state\n\n    # Properties\n    # Validations note: We know train & test fit each other so all validations can be run only on train\n\n    @property\n    def train(self) -> VisionData:\n        \"\"\"Return train if exists, otherwise raise error.\"\"\"\n        if self._train is None:\n            raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without train dataset')\n        return self._train\n\n    @property\n    def test(self) -> VisionData:\n        \"\"\"Return test if exists, otherwise raise error.\"\"\"\n        if self._test is None:\n            raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without test dataset')\n        return self._test\n\n    @property\n    def model(self) -> nn.Module:\n        \"\"\"Return & validate model if model exists, otherwise raise error.\"\"\"\n        if self._model is None:\n            raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without model')\n        return self._model\n\n    @property\n    def model_name(self):\n        \"\"\"Return model name.\"\"\"\n        return self._model_name\n\n    @property\n    def device(self) -> torch.device:\n        \"\"\"Return device specified by the user.\"\"\"\n        return self._device\n\n    def have_test(self):\n        \"\"\"Return whether there is test dataset defined.\"\"\"\n        return self._test is not None\n\n    def assert_task_type(self, *expected_types: TaskType):\n        \"\"\"Assert task_type matching given types.\"\"\"\n        if self.train.task_type not in expected_types:\n            raise ModelValidationError(\n                f'Check is irrelevant for task of type {self.train.task_type}')\n        return True\n\n    def get_data_by_kind(self, kind: DatasetKind):\n        \"\"\"Return the relevant VisionData by given kind.\"\"\"\n        if kind == DatasetKind.TRAIN:\n            return self.train\n        elif kind == DatasetKind.TEST:\n            return self.test\n        else:\n            raise DeepchecksValueError(f'Unexpected dataset kind {kind}')\n", "path": "deepchecks/vision/context.py"}], "after_files": [{"content": "# ----------------------------------------------------------------------------\n# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)\n#\n# This file is part of Deepchecks.\n# Deepchecks is distributed under the terms of the GNU Affero General\n# Public License (version 3 or later).\n# You should have received a copy of the GNU Affero General Public License\n# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.\n# ----------------------------------------------------------------------------\n#\n\"\"\"Module for base vision context.\"\"\"\nimport logging\nfrom typing import Mapping, Union, Iterable, Any, Tuple\n\nimport torch\nfrom torch import nn\nfrom ignite.metrics import Metric\n\nfrom deepchecks.core import DatasetKind\nfrom deepchecks.vision.vision_data import VisionData, TaskType\nfrom deepchecks.vision.utils.validation import apply_to_tensor\nfrom deepchecks.core.errors import (\n    DatasetValidationError, DeepchecksNotImplementedError, ModelValidationError,\n    DeepchecksNotSupportedError, DeepchecksValueError\n)\n\n\n__all__ = ['Context']\n\n\nlogger = logging.getLogger('deepchecks')\n\n\nclass Batch:\n    \"\"\"Represents dataset batch returned by the dataloader during iteration.\"\"\"\n\n    def __init__(\n        self,\n        batch: Tuple[Iterable[Any], Iterable[Any]],\n        context: 'Context',\n        dataset_kind: DatasetKind\n    ):\n        self._context = context\n        self._dataset_kind = dataset_kind\n        self._batch = apply_to_tensor(batch, lambda it: it.to(self._context.device))\n        self._labels = None\n        self._predictions = None\n        self._images = None\n\n    @property\n    def labels(self):\n        if self._labels is None:\n            dataset = self._context.get_data_by_kind(self._dataset_kind)\n            self._labels = dataset.batch_to_labels(self._batch)\n        return self._labels\n\n    @property\n    def predictions(self):\n        if self._predictions is None:\n            dataset = self._context.get_data_by_kind(self._dataset_kind)\n            self._predictions = dataset.infer_on_batch(self._batch, self._context.model, self._context.device)\n        return self._predictions\n\n    @property\n    def images(self):\n        if self._images is None:\n            dataset = self._context.get_data_by_kind(self._dataset_kind)\n            self._images = dataset.batch_to_images(self._batch)\n        return self._images\n\n    def __getitem__(self, index):\n        return self._batch[index]\n\n\nclass Context:\n    \"\"\"Contains all the data + properties the user has passed to a check/suite, and validates it seamlessly.\n\n    Parameters\n    ----------\n    train : VisionData , default: None\n        Dataset or DataFrame object, representing data an estimator was fitted on\n    test : VisionData , default: None\n        Dataset or DataFrame object, representing data an estimator predicts on\n    model : BasicModel , default: None\n        A scikit-learn-compatible fitted estimator instance\n    model_name: str , default: ''\n        The name of the model\n    scorers : Mapping[str, Metric] , default: None\n        dict of scorers names to a Metric\n    scorers_per_class : Mapping[str, Metric] , default: None\n        dict of scorers for classification without averaging of the classes.\n        See <a href=\n        \"https://scikit-learn.org/stable/modules/model_evaluation.html#from-binary-to-multiclass-and-multilabel\">\n        scikit-learn docs</a>\n    device : Union[str, torch.device], default: 'cpu'\n        processing unit for use\n    random_state : int\n        A seed to set for pseudo-random functions\n    n_samples : int, default: None\n    \"\"\"\n\n    def __init__(self,\n                 train: VisionData = None,\n                 test: VisionData = None,\n                 model: nn.Module = None,\n                 model_name: str = '',\n                 scorers: Mapping[str, Metric] = None,\n                 scorers_per_class: Mapping[str, Metric] = None,\n                 device: Union[str, torch.device, None] = 'cpu',\n                 random_state: int = 42,\n                 n_samples: int = None\n                 ):\n        # Validations\n        if train is None and test is None and model is None:\n            raise DeepchecksValueError('At least one dataset (or model) must be passed to the method!')\n        if test and not train:\n            raise DatasetValidationError('Can\\'t initialize context with only test. if you have single dataset, '\n                                         'initialize it as train')\n        if train and test:\n            train.validate_shared_label(test)\n\n        self._device = torch.device(device) if isinstance(device, str) else (device if device else torch.device('cpu'))\n\n        if model is not None:\n            if not isinstance(model, nn.Module):\n                logger.warning('Model is not a torch.nn.Module. Deepchecks can\\'t validate that model is in '\n                               'evaluation state.')\n            else:\n                if model.training:\n                    raise DatasetValidationError('Model is not in evaluation state. Please set model training '\n                                                 'parameter to False or run model.eval() before passing it.')\n            for dataset, dataset_type in zip([train, test], ['train', 'test']):\n                if dataset is not None:\n                    try:\n                        dataset.validate_prediction(next(iter(dataset.data_loader)), model, self._device)\n                    except DeepchecksNotImplementedError:\n                        logger.warning('validate_prediction() was not implemented in %s dataset, '\n                                       'some checks will not run', dataset_type)\n\n        # The copy does 2 things: Sample n_samples if parameter exists, and shuffle the data.\n        # we shuffle because the data in VisionData is set to be sampled in a fixed order (in the init), so if the user\n        # wants to run without random_state we need to forcefully shuffle (to have different results on different runs\n        # from the same VisionData object), and if there is a random_state the shuffle will always have same result\n        if train:\n            train = train.copy(shuffle=True, n_samples=n_samples, random_state=random_state)\n        if test:\n            test = test.copy(shuffle=True, n_samples=n_samples, random_state=random_state)\n\n        self._train = train\n        self._test = test\n        self._model = model\n        self._user_scorers = scorers\n        self._user_scorers_per_class = scorers_per_class\n        self._model_name = model_name\n        self.random_state = random_state\n\n    # Properties\n    # Validations note: We know train & test fit each other so all validations can be run only on train\n\n    @property\n    def train(self) -> VisionData:\n        \"\"\"Return train if exists, otherwise raise error.\"\"\"\n        if self._train is None:\n            raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without train dataset')\n        return self._train\n\n    @property\n    def test(self) -> VisionData:\n        \"\"\"Return test if exists, otherwise raise error.\"\"\"\n        if self._test is None:\n            raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without test dataset')\n        return self._test\n\n    @property\n    def model(self) -> nn.Module:\n        \"\"\"Return & validate model if model exists, otherwise raise error.\"\"\"\n        if self._model is None:\n            raise DeepchecksNotSupportedError('Check is irrelevant for Datasets without model')\n        return self._model\n\n    @property\n    def model_name(self):\n        \"\"\"Return model name.\"\"\"\n        return self._model_name\n\n    @property\n    def device(self) -> torch.device:\n        \"\"\"Return device specified by the user.\"\"\"\n        return self._device\n\n    def have_test(self):\n        \"\"\"Return whether there is test dataset defined.\"\"\"\n        return self._test is not None\n\n    def assert_task_type(self, *expected_types: TaskType):\n        \"\"\"Assert task_type matching given types.\"\"\"\n        if self.train.task_type not in expected_types:\n            raise ModelValidationError(\n                f'Check is irrelevant for task of type {self.train.task_type}')\n        return True\n\n    def get_data_by_kind(self, kind: DatasetKind):\n        \"\"\"Return the relevant VisionData by given kind.\"\"\"\n        if kind == DatasetKind.TRAIN:\n            return self.train\n        elif kind == DatasetKind.TEST:\n            return self.test\n        else:\n            raise DeepchecksValueError(f'Unexpected dataset kind {kind}')\n", "path": "deepchecks/vision/context.py"}]}