code: def parse_task_model_outputs(
      tasks: List[RecTaskInfo],
      model_out: Dict[str, torch.Tensor],
      required_inputs_list: Optional[List[str]] = None,
  ) -> Tuple[
      Dict[str, torch.Tensor],
      Dict[str, torch.Tensor],
      Dict[str, torch.Tensor],
      Dict[str, torch.Tensor],
  ]:
      all_labels: Dict[str, torch.Tensor] = {}
      all_predictions: Dict[str, torch.Tensor] = {}
      all_weights: Dict[str, torch.Tensor] = {}
      all_required_inputs: Dict[str, torch.Tensor] = {}
      for task in tasks:
          labels, predictions, weights = parse_model_outputs(
              task.label_name,
              task.prediction_name,
              task.weight_name,
              model_out,
          )
          if predictions is not None and weights is not None:
              if not is_empty_signals(labels, predictions, weights):
                  all_labels[task.name] = labels
                  all_predictions[task.name] = predictions
                  all_weights[task.name] = weights
          else:
              if torch.numel(labels) > 0:
                  all_labels[task.name] = labels
  
      if required_inputs_list is not None:
          all_required_inputs = parse_required_inputs(
              model_out, required_inputs_list
          )
  
      return (
          all_labels,
          all_predictions,
          all_weights,
          all_required_inputs,
      )
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  from torchrec.metrics.rec_metric import RecTaskInfo
label_desc: Use image node_id 4 for calling a global function with example usage: parse_task_model_outputs(tasks, model_out, required_inputs_list) and returns: all_labels,  all_predictions,  all_weights,  all_required_inputs