class_docstr: Contains all the data + properties the user has passed to a check/suite, and validates it seamlessly.
  
  Parameters
  ----------
  train_dataset : Union[TextData, None] , default: None
      TextData object, representing data an estimator was fitted on
  test_dataset : Union[TextData, None] , default: None
      TextData object, representing data an estimator predicts on
  with_display : bool , default: True
      flag that determines if checks will calculate display (redundant in some checks).
  train_pred : Union[TTextPred, None] , default: None
      predictions on train dataset
  test_pred : Union[TTextPred, None] , default: None
      predictions on test dataset
  train_proba : Union[TTextProba, None] , default: None
      probabilities on train dataset
  test_proba : Union[TTextProba, None] , default: None
      probabilities on test dataset
  model_classes : Optional[List] , default: None
      list of classes known to the model
  random_state: int, default 42
      A seed to set for pseudo-random functions , primarily sampling.
class_docstr_tok: ["Contains","all","the","data","+","properties","the","user","has","passed","to","a","check\/suite",",","and","validates","it","seamlessly",".","Parameters","--","--","--","--","--","train_dataset",":","Union","[","TextData",",","None","]",",","default",":","None","TextData","object",",","representing","data","an","estimator","was","fitted","on","test_dataset",":","Union","[","TextData",",","None","]",",","default",":","None","TextData","object",",","representing","data","an","estimator","predicts","on","with_display",":","bool",",","default",":","True","flag","that","determines","if","checks","will","calculate","display","(","redundant","in","some","checks",")",".","train_pred",":","Union","[","TTextPred",",","None","]",",","default",":","None","predictions","on","train","dataset","test_pred",":","Union","[","TTextPred",",","None","]",",","default",":","None","predictions","on","test","dataset","train_proba",":","Union","[","TTextProba",",","None","]",",","default",":","None","probabilities","on","train","dataset","test_proba",":","Union","[","TTextProba",",","None","]",",","default",":","None","probabilities","on","test","dataset","model_classes",":","Optional","[","List","]",",","default",":","None","list","of","classes","known","to","the","model","random_state",":","int",",","default","42","A","seed","to","set","for","pseudo-random","functions",",","primarily","sampling","."]
docstr: Infer the task type.
docstr_tok: ["Infer","the","task","type","."]
code: def infer_task_type(train_dataset: TextData, test_dataset: TextData):
      """Infer the task type."""
      if not test_dataset:
          return train_dataset.task_type
      elif train_dataset.task_type != test_dataset.task_type:
          raise DeepchecksValueError(
              f"datasets must have the same task type. Received "
              f"{train_dataset.task_type.value} for train and "
              f"{test_dataset.task_type.value} for test"
          )
      return train_dataset.task_type
  
imports: import typing
  from operator import itemgetter
  import numpy
  from deepchecks.core.context import BaseContext
  from deepchecks.core.errors import DatasetValidationError, DeepchecksNotSupportedError, DeepchecksValueError, ModelValidationError
  from deepchecks.nlp.input_validations import _validate_multilabel, _validate_text_classification, _validate_token_classification, compare_dataframes
  from deepchecks.nlp.metric_utils.scorers import init_validate_scorers
  from deepchecks.nlp.metric_utils.token_classification import get_default_token_scorers, get_scorer_dict, validate_scorers
  from deepchecks.nlp.task_type import TaskType
  from deepchecks.nlp.text_data import TextData
  from deepchecks.nlp.utils.data_inference import infer_observed_and_model_labels
  from deepchecks.tabular.metric_utils import DeepcheckScorer, get_default_scorers
  from deepchecks.tabular.utils.task_type import TaskType
  from deepchecks.utils.docref import doclink
  from deepchecks.utils.logger import get_logger
  from deepchecks.utils.typing import BasicModel
  from deepchecks.utils.validation import is_sequence_not_str
label_desc: Use image node_id 7 for calling the Context obj's underlying member method code with example usage: obj.infer_task_type(train_dataset, test_dataset) and returns: train_dataset, train_dataset