code: def test_integration(p, r, average, output_transform):
      np.random.seed(1)
  
      n_iters = 10
      batch_size = 10
      n_classes = 10
  
      y_true = (
          np.arange(0, n_iters * batch_size, dtype="int64") % n_classes
      )
      y_pred = 0.2 * np.random.rand(n_iters * batch_size, n_classes)
      for i in range(n_iters * batch_size):
          if np.random.rand() > 0.4:
              y_pred[i, y_true[i]] = 1.0
          else:
              j = np.random.randint(0, n_classes)
              y_pred[i, j] = 0.7
  
      y_true_batch_values = iter(y_true.reshape(n_iters, batch_size))
      y_pred_batch_values = iter(
          y_pred.reshape(n_iters, batch_size, n_classes)
      )
  
      def update_fn(engine, batch):
          y_true_batch = next(y_true_batch_values)
          y_pred_batch = next(y_pred_batch_values)
          if output_transform is not None:
              return {
                  "y_pred": torch.from_numpy(y_pred_batch),
                  "y": torch.from_numpy(y_true_batch),
              }
          return torch.from_numpy(y_pred_batch), torch.from_numpy(
              y_true_batch
          )
  
      evaluator = Engine(update_fn)
  
      f2 = Fbeta(
          beta=2.0,
          average=average,
          precision=p,
          recall=r,
          output_transform=output_transform,
      )
      f2.attach(evaluator, "f2")
  
      data = list(range(n_iters))
      state = evaluator.run(data, max_epochs=1)
  
      f2_true = fbeta_score(
          y_true,
          np.argmax(y_pred, axis=-1),
          average="macro" if average else None,
          beta=2.0,
      )
      np.testing.assert_allclose(
          np.array(f2_true), np.array(state.metrics["f2"])
      )
  
file_path: ignite/tests/ignite/metrics/test_fbeta.py
imports: import os
  import numpy
  import pytest
  import torch
  from sklearn.metrics import fbeta_score
  import ignite.distributed
  from ignite.engine import Engine
  from ignite.metrics import Fbeta, Precision, Recall
label_desc: Use image node_id 3 for calling a global function with example usage: test_integration(p, r, average, output_transform) and returns: torch,  torch, dict