class_docstr: HeadsDict class manages the construction and forward pass for
  multiple possible heads for multi-task learning.
  Construction from list or dict configs is supported,
  take a look at `build_heads_dict(head_configs, tasks, losses)`.
code: def _process_head_output(
      self,
      outputs: Union[Dict, Tensor],
      loss_name: str,
      head_name: str,
      sample_list: Dict[str, Tensor],
  ) -> Dict[str, Tensor]:
      if (
          isinstance(outputs, collections.abc.MutableMapping)
          and "losses" in outputs
      ):
          return outputs
  
      if (
          isinstance(outputs, collections.abc.MutableMapping)
          and "scores" in outputs
      ):
          logits = outputs["scores"]
      else:
          logits = outputs
      logits = logits.contiguous().view(-1, logits.size(-1))
  
      if loss_name is None:
          raise ValueError(
              f"Transformer head {head_name} must either \
                                  define a 'loss' in its config or return \
                                  a dict that contains key 'losses'."
          )
      output = self.losses[loss_name](sample_list, {"scores": logits})
      return {"losses": output, "scores": logits}
  
file_path: mmf/mmf/models/transformers/heads/utils.py
imports: import collections
  import collections.abc
  from typing import Dict, List, Optional, Union
  from mmf.common.registry import registry
  from torch import nn, Tensor
label_desc: Use image node_id 3 for calling the HeadsDict obj's underlying member method code with example usage: obj._process_head_output(outputs, loss_name, head_name, sample_list) and returns: dict, outputs