code: def _functional_test(
      preds: torch.Tensor,
      target: torch.Tensor,
      metric_functional: Callable,
      sk_metric: Callable,
      metric_args: dict = {},
      atol: float = 1e-8,
  ):
      """Utility function doing the actual comparison between lightning functional metric
      and reference metric.
      Args:
          preds: torch tensor with predictions
          target: torch tensor with targets
          metric_functional: lightning metric functional that should be tested
          sk_metric: callable function that is used for comparison
          metric_args: dict with additional arguments used for class initialization
      """
      metric = partial(metric_functional, **metric_args)
  
      for i in range(NUM_BATCHES):
          lightning_result = metric(preds[i], target[i])
          sk_result = sk_metric(preds[i], target[i])
  
          # assert its the same
          assert np.allclose(
              lightning_result.numpy(), sk_result, atol=atol
          )
  
imports: import os
  import pickle
  import sys
  from functools import partial
  from typing import Callable, Optional
  import numpy
  import pytest
  import torch
  from scipy.stats import entropy
  from torch.distributions.utils import logits_to_probs
  from torch.multiprocessing import Pool, set_start_method
  from torchmetrics import Metric
  from nemo.collections.common.metrics import GlobalAverageLossMetric, Perplexity
label_desc: Use image node_id 3 for calling a global function with example usage: _functional_test(preds, target, metric_functional, sk_metric, metric_args, atol) without return types