code: def forward(self, logits: np.ndarray, labels: np.ndarray) -> float:  # type: ignore
      if metrics is None:
          return 0.0
      logits = get_full_logits(logits)
      num_classes = logits.shape[1]
      classes = logits.argmax(1)
      labels = labels.ravel()
      if num_classes == 2:
          return metrics.f1_score(labels, classes)
      return metrics.f1_score(labels, classes, average=self.average)
  
imports: import numpy
  from typing import Any
  from typing import Tuple
  from typing import Optional
  from cftool.misc import print_warning
  from cftool.array import iou
  from cftool.array import corr
  from cftool.array import softmax
  from cftool.array import get_full_logits
  from cftool.array import get_label_predictions
  from cftool.types import np_dict_type
  from .schema import IMetric
  from .schema import IDataLoader
  from .constants import LABEL_KEY
  from .constants import PREDICTIONS_KEY
  from .misc.toolkit import insert_intermediate_dims
label_desc: Use image node_id 4 for calling the F1Score obj's underlying member method code with example usage: obj.forward(logits, labels) and returns: metrics, int, metrics