code: def weighted_correctly_classified(
      logits: jnp.ndarray,
      targets: jnp.ndarray,
      weights: Optional[jnp.ndarray] = None,
  ) -> jnp.ndarray:
      """Computes weighted number of correctly classified over the given batch.
  
      Args:
       logits: Output of model in shape [batch, ..., 1].
       targets: Binary array of shape [batch, ..., 1].
       weights: None or array of shape [batch, ...] (rank of targets -1).
  
      Returns:
        The number of correctly classified examples in the given batch.
      """
      if logits.ndim != targets.ndim:
          raise ValueError(
              "Incorrect shapes. Got shape %s logits and %s one_hot_targets"
              % (str(logits.shape), str(targets.shape))
          )
      preds = logits >= 0.0
      correct = jnp.equal(preds, targets)
  
      if weights is not None:
          correct = model_utils.apply_weights(correct, weights)
  
      return correct.astype(jnp.int32)
  
imports: import functools
  from typing import Any, Dict, Mapping, Optional, Tuple, Union
  import immutabledict
  import jax.numpy
  import ml_collections
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import model_utils
  from scenic.projects.unloc import temporal_localization_base_model
label_desc: Use image node_id 5 for calling a global function with example usage: weighted_correctly_classified(logits, targets, weights) and returns: correct