code: def parse_model_outputs(
      label_name: str,
      prediction_name: str,
      weight_name: str,
      model_out: Dict[str, torch.Tensor],
  ) -> Tuple[
      torch.Tensor, Optional[torch.Tensor], Optional[torch.Tensor]
  ]:
      labels = model_out[label_name].squeeze()
      if not prediction_name:
          assert (
              not weight_name
          ), "weight name must be empty if prediction name is empty"
          return (labels, None, None)
      assert isinstance(labels, torch.Tensor)
      predictions = model_out[prediction_name].squeeze()
      assert isinstance(predictions, torch.Tensor)
      weights = model_out[weight_name].squeeze()
      assert isinstance(weights, torch.Tensor)
  
      if not is_empty_signals(labels, predictions, weights):
          if labels.dim() == predictions.dim():
              assert (
                  torch.numel(labels) == torch.numel(predictions)
              ) and (torch.numel(labels) == torch.numel(weights)), (
                  "Expect the same number of elements in labels, predictions, and weights. "
                  f"Instead got {torch.numel(labels)}, {torch.numel(predictions)}, "
                  f"{torch.numel(weights)}"
              )
          else:  # For multiclass models, labels.size() = (batch_size), and predictions.size() = (batch_size, number_of_classes)
              assert torch.numel(labels) == torch.numel(
                  predictions
              ) / predictions.size()[-1] and torch.numel(
                  labels
              ) == torch.numel(
                  weights
              )
  
          # non-empty tensors need to have rank 1
          if len(labels.size()) == 0:
              labels = labels.unsqueeze(0)
              predictions = predictions.unsqueeze(0)
              weights = weights.unsqueeze(0)
  
      return labels, predictions, weights
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  from torchrec.metrics.rec_metric import RecTaskInfo
label_desc: Use image node_id 2 for calling a global function with example usage: parse_model_outputs(label_name, prediction_name, weight_name, model_out) and returns: labels,  predictions,  weights, labels,  None,  None