class_docstr: Modules which have the same shared_module_key and type share parameters.
  Only the first instance of such module should be configured in tasks list.
class_docstr_tok: ["Modules","which","have","the","same","shared_module_key","and","type","share","parameters",".","Only","the","first","instance","of","such","module","should","be","configured","in","tasks","list","."]
code: def from_config(
      cls,
      task_config: Config,
      metadata=None,
      model_state=None,
      tensorizers=None,
      rank=0,
      world_size=1,
  ):
      print("Task parameters:\n")
      pprint(config_to_json(type(task_config), task_config))
  
      data_handlers = OrderedDict()
      exporters = OrderedDict()
      for name, task in task_config.tasks.items():
          featurizer = create_featurizer(task.featurizer, task.features)
          data_handlers[name] = create_data_handler(
              task.data_handler,
              task.features,
              task.labels,
              featurizer=featurizer,
          )
      data_handler = DisjointMultitaskDataHandler(
          task_config.data_handler,
          data_handlers,
          target_task_name=task_config.target_task_name,
      )
      print("\nLoading data...")
      if metadata:
          data_handler.load_metadata(metadata)
      else:
          data_handler.init_metadata()
  
      metadata = data_handler.metadata
      exporters = {
          name: (
              create_exporter(
                  task.exporter,
                  task.features,
                  task.labels,
                  data_handler.data_handlers[name].metadata,
                  task.model,
              )
              if task.exporter
              else None
          )
          for name, task in task_config.tasks.items()
      }
      task_weights = {
          task_name: task_config.task_weights.get(task_name, 1)
          for task_name in task_config.tasks.keys()
      }
      metric_reporter = DisjointMultitaskMetricReporter(
          OrderedDict(
              (
                  name,
                  create_metric_reporter(
                      task.metric_reporter, metadata[name]
                  ),
              )
              for name, task in task_config.tasks.items()
          ),
          loss_weights=task_weights,
          target_task_name=task_config.target_task_name,
          use_subtask_select_metric=(
              task_config.metric_reporter.use_subtask_select_metric
          ),
      )
      model = DisjointMultitaskModel(
          OrderedDict(
              (
                  name,
                  create_model(
                      task.model, task.features, metadata[name]
                  ),
              )
              for name, task in task_config.tasks.items()
          ),
          loss_weights=task_weights,
      )
      if model_state:
          model.load_state_dict(model_state)
      if cuda.CUDA_ENABLED:
          model = model.cuda()
  
      return cls(
          target_task_name=task_config.target_task_name,
          exporters=exporters,
          trainer=create_trainer(task_config.trainer, model),
          data_handler=data_handler,
          model=model,
          metric_reporter=metric_reporter,
      )
  
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 DisjointMultitask obj's underlying member method code with example usage: obj.from_config(cls, task_config, metadata, model_state, tensorizers, rank, world_size) and returns: cls