code: def f1_score_with_invalid(targets, predictions):
      """Compute F1 score, but any prediction != 0 or 1 is counted as incorrect.
  
      Args:
        targets: np.ndarray of targets, either 0 or 1
        predictions: np.ndarray of predictions, any integer value
  
      Returns:
        F1 score, where any prediction != 0 or 1 is counted as wrong.
      """
      targets, predictions = np.asarray(targets), np.asarray(
          predictions
      )
      # Get indices of invalid predictions
      invalid_idx_mask = np.logical_and(
          predictions != 0, predictions != 1
      )
      # For any prediction != 0 or 1, set it to the opposite of what the target is
      predictions[invalid_idx_mask] = 1 - targets[invalid_idx_mask]
      return {
          "f1": 100 * sklearn.metrics.f1_score(targets, predictions)
      }
  
imports: import collections
  import itertools
  import re
  import string
  from typing import Any, Dict, Mapping, Optional, Sequence, Tuple, Union
  from absl import logging
  import editdistance
  import flax
  import jax.numpy
  import numpy
  import sacrebleu
  import scipy.stats
  import seqio
  import sklearn.metrics
  from t5.evaluation import qa_utils
  import tensorflow.compat.v2
  from rouge_score import rouge_scorer
  from rouge_score import scoring
label_desc: Use image node_id 14 for calling a global function with example usage: f1_score_with_invalid(targets, predictions) and returns: dict