code: def masked_correct_predictions(
      targets: Tensor, preds: Tensor, targets_sequence_lengths: Tensor
  ) -> Tensor:
      """Masks out special symbols, and returns tensor of correct predictions.
  
      Args:
          targets: 2D tensor [batch_size, sequence_length]
          preds: 2D tensor [batch_size, sequence_length]
  
      Returns:
          1D tensor of all correct predictions.
      """
      correct_preds = preds == targets
  
      mask = sequence_mask(
          lengths=targets_sequence_lengths,
          maxlen=correct_preds.shape[1],
          dtype=torch.int32,
      )
      _, masked_correct_preds = dynamic_partition(
          data=correct_preds, partitions=mask, num_partitions=2
      )
  
      return masked_correct_preds.type(torch.float32)
  
file_path: ludwig/ludwig/utils/metric_utils.py
imports: from collections import defaultdict, namedtuple
  from typing import Dict, List, Optional
  import torch
  from torch import Tensor
  from torchmetrics.metric import Metric
  from ludwig.constants import COMBINED, LOSS, NAME, TYPE
  from ludwig.modules.metric_registry import get_metric_names_for_type
  from ludwig.types import FeatureConfigDict
label_desc: Use image node_id 3 for calling a global function with example usage: masked_correct_predictions(targets, preds, targets_sequence_lengths) and returns: masked_correct_preds