class_docstr: Predictor for multitask models.
  
  Registered as a `Predictor` with name "multitask".
  
  This predictor is tightly coupled to `MultiTaskDatasetReader` and `MultiTaskModel`, and will not work if
  used with other readers or models.
code: def __init__(
      self,
      model: MultiTaskModel,
      dataset_reader: MultiTaskDatasetReader,
  ) -> None:
      if not isinstance(dataset_reader, MultiTaskDatasetReader):
          raise ConfigurationError(self._WRONG_READER_ERROR)
  
      if not isinstance(model, MultiTaskModel):
          raise ConfigurationError(
              "MultiTaskPredictor is designed to work only with MultiTaskModel."
          )
  
      super().__init__(model, dataset_reader)
  
      self.predictors = {}
      for name, head in model._heads.items():
          predictor_name = head.default_predictor
          predictor_class: Type[Predictor] = (
              Predictor.by_name(predictor_name) if predictor_name is not None else Predictor  # type: ignore
          )
          self.predictors[name] = predictor_class(
              model, dataset_reader.readers[name].inner
          )
  
file_path: allennlp/allennlp/predictors/multitask.py
imports: import collections
  from typing import Type, List, Dict
  from allennlp.common import JsonDict
  from allennlp.data import Instance
  from allennlp.models.multitask import MultiTaskModel
  from allennlp.predictors.predictor import Predictor
  from allennlp.common.util import sanitize
  from allennlp.data.fields import MetadataField
  from allennlp.common.checks import ConfigurationError
  from allennlp.data.dataset_readers import MultiTaskDatasetReader
label_desc: Use image node_id 1 to create a new MultiTaskPredictor object from inherited base classes: Predictor with example: obj = MultiTaskPredictor(model, dataset_reader)