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","."]
code: def __init__(
      self,
      train_dataset: t.Union[TextData, None] = None,
      test_dataset: t.Union[TextData, None] = None,
      with_display: bool = True,
      train_pred: t.Optional[TTextPred] = None,
      test_pred: t.Optional[TTextPred] = None,
      train_proba: t.Optional[TTextProba] = None,
      test_proba: t.Optional[TTextProba] = None,
      model_classes: t.Optional[t.List] = None,
      random_state: int = 42,
  ):
      # Validations
      if train_dataset is None and test_dataset is None:
          raise DatasetValidationError(
              "Check must be given at least one dataset"
          )
      if train_dataset is not None:
          train_dataset = TextData.cast_to_dataset(train_dataset)
          if train_dataset.name is None:
              train_dataset.name = "Train"
      if test_dataset is not None:
          test_dataset = TextData.cast_to_dataset(test_dataset)
          if test_dataset.name is None:
              test_dataset.name = "Test"
  
      # If both dataset, validate they fit each other
      if train_dataset and test_dataset:
          if (
              test_dataset.has_label()
              and train_dataset.has_label()
              and not train_dataset.validate_textdata_compatibility(
                  test_dataset
              )
          ):
              raise DatasetValidationError(
                  "train_dataset and test_dataset must share the same label and task type"
              )
  
          if (
              train_dataset._properties is not None
              and test_dataset._properties is not None
          ):
              result = compare_dataframes(
                  train=train_dataset._properties,
                  test=test_dataset._properties,
                  train_categorical_columns=train_dataset._cat_properties,
                  test_categorical_columns=test_dataset._cat_properties,
              )
              self._common_datasets_properties = result.common
              if result.difference is not None:
                  get_logger().warning(
                      "Train and Test datasets have different properties, "
                      "only common properties will be used in train-test checks.\n"
                      "Properties present only in train dataset: %s\n"
                      "Properties present only in test dataset: %s\n"
                      "Properties with different types: %s\n",
                      result.difference.only_in_train,
                      result.difference.only_in_test,
                      result.difference.types_mismatch,
                  )
  
      if test_dataset and not train_dataset:
          raise DatasetValidationError(
              "Can't initialize context with only test_dataset. if you have single "
              "dataset, initialize it as train_dataset"
          )
  
      if model_classes is not None:
          if (not is_sequence_not_str(model_classes)) or len(
              model_classes
          ) == 0:
              raise DeepchecksValueError(
                  "model_classes must be a non-empty sequence"
              )
          if sorted(model_classes) != model_classes:
              supported_models_link = doclink(
                  "nlp-supported-predictions-format",
                  template="For more information please refer to the Supported Tasks guide {link}",
              )
              raise DeepchecksValueError(
                  f"Received unsorted model_classes. {supported_models_link}"
              )
  
      self._task_type = self.infer_task_type(
          train_dataset, test_dataset
      )
  
      (
          self._observed_classes,
          self._model_classes,
      ) = infer_observed_and_model_labels(
          train_dataset=train_dataset,
          test_dataset=test_dataset,
          model=None,
          y_pred_train=train_pred,
          y_pred_test=test_pred,
          model_classes=model_classes,
          task_type=self.task_type,
      )
  
      if any(
          x is not None
          for x in (train_pred, test_pred, train_proba, test_proba)
      ):
          self._model = _DummyModel(
              train=train_dataset,
              test=test_dataset,
              y_pred_train=train_pred,
              y_pred_test=test_pred,
              y_proba_train=train_proba,
              y_proba_test=test_proba,
              model_classes=self.model_classes,
          )
      else:
          self._model = None
  
      self._train = train_dataset
      self._test = test_dataset
      self._validated_model = False
      self._with_display = with_display
      self.random_state = random_state
  
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 1 to create a new Context object from inherited base classes: BaseContext with example: obj = Context(train_dataset, test_dataset, with_display, train_pred, test_pred, train_proba, test_proba, model_classes, random_state)