class_docstr: Multitask training based on underlying subtasks. To share parameters between modules
  from different tasks, specify the same shared_module_key. Only the first instance of
  each shared module should be configured in tasks list. Only the multitask trainer
  (not the per-task trainers) is used.
class_docstr_tok: ["Multitask","training","based","on","underlying","subtasks",".","To","share","parameters","between","modules","from","different","tasks",",","specify","the","same","shared_module_key",".","Only","the","first","instance","of","each","shared","module","should","be","configured","in","tasks","list",".","Only","the","multitask","trainer","(","not","the","per-task","trainers",")","is","used","."]
code: def from_config(
      cls,
      task_config: Config,
      unused_metadata=None,
      model_state=None,
      tensorizers=None,
      rank=0,
      world_size=1,
  ):
      data_dict = OrderedDict()
      models = OrderedDict()
      metric_reporters = OrderedDict()
      tensorizers_dict = tensorizers or {}
      # We can't really re-use the tensorizers, and the tensorizers saved for disjoint
      # multitask are an empty dict right now anyway. Really we should serialize
      # all of the subtasks individually.
      for name, task in task_config.tasks.items():
          tensorizers, data = cls._init_tensorizers(
              task, tensorizers_dict.get(name), rank, world_size
          )
          data_dict[name] = data
          models[name] = NewTask._init_model(task.model, tensorizers)
          metric_reporters[name] = create_component(
              ComponentType.METRIC_REPORTER,
              task.metric_reporter,
              tensorizers=tensorizers,
          )
  
      task_weights = {
          task_name: task_config.task_weights.get(task_name, 1.0)
          for task_name in task_config.tasks.keys()
      }
      data = DisjointMultitaskData.from_config(
          task_config.data,
          data_dict=data_dict,
          rank=rank,
          world_size=world_size,
      )
      # for serialization
      data.tensorizers = {
          name: data.data_dict[name].tensorizers
          for name in data.data_dict
      }
      model = NewDisjointMultitaskModel(
          models, loss_weights=task_weights
      )
      if model_state:
          model.load_state_dict(model_state)
      metric_reporter = DisjointMultitaskMetricReporter(
          metric_reporters,
          loss_weights=task_weights,
          target_task_name=task_config.target_task_name,
          use_subtask_select_metric=(
              task_config.metric_reporter.use_subtask_select_metric
          ),
      )
      trainer = create_trainer(task_config.trainer, model)
      log_class_usage(__class__)
      return cls(data, model, metric_reporter, trainer)
  
imports: from collections import OrderedDict
  from pprint import pprint
  from typing import Dict, Optional
  from pytext.config import config_to_json
  from pytext.config.component import ComponentType, create_component, create_data_handler, create_exporter, create_featurizer, create_metric_reporter, create_model, create_optimizer, create_trainer
  from pytext.data import DisjointMultitaskData, DisjointMultitaskDataHandler
  from pytext.metric_reporters.disjoint_multitask_metric_reporter import DisjointMultitaskMetricReporter
  from pytext.models.disjoint_multitask_model import DisjointMultitaskModel, NewDisjointMultitaskModel
  from pytext.optimizer.scheduler import Scheduler
  from pytext.utils import cuda
  from pytext.utils.usage import log_class_usage
  from .None import _NewTask, NewTask, Task_Deprecated, TaskBase
label_desc: Use image node_id 1 for calling the NewDisjointMultitask obj's underlying member method code with example usage: obj.from_config(cls, task_config, unused_metadata, model_state, tensorizers, rank, world_size) and returns: cls