code: def _squad_score_ddp(
      rank, world_size, pred, targets, exact_match, f1
  ):
      """Define a DDP process for SQuAD metric."""
      os.environ["MASTER_ADDR"] = "localhost"
      os.environ["MASTER_PORT"] = "12355"
      dist.init_process_group("gloo", rank=rank, world_size=world_size)
      squad_metric = SQuAD()
      squad_metric.update(pred, targets)
      metrics_score = squad_metric.compute()
      _assert_tensor(metrics_score["exact_match"])
      _assert_tensor(metrics_score["f1"])
      _assert_allclose(metrics_score["exact_match"], exact_match)
      _assert_allclose(metrics_score["f1"], f1)
      dist.destroy_process_group()
  
file_path: torchmetrics/tests/unittests/text/test_squad.py
imports: import os
  import pytest
  import torch
  import torch.distributed
  import torch.multiprocessing
  from torchmetrics.functional.text import squad
  from torchmetrics.text.squad import SQuAD
  from unittests.helpers.testers import _assert_allclose, _assert_tensor
  from unittests.text.inputs import _inputs_squad_batch_match, _inputs_squad_exact_match, _inputs_squad_exact_mismatch
label_desc: Use image node_id 3 for calling a global function with example usage: _squad_score_ddp(rank, world_size, pred, targets, exact_match, f1) without return types