code: def setup_ddp(rank, world_size):
      """Initialize ddp environment."""
      global CURRENT_PORT
  
      os.environ["MASTER_ADDR"] = "localhost"
      os.environ["MASTER_PORT"] = str(CURRENT_PORT)
  
      CURRENT_PORT += 1
      if CURRENT_PORT > MAX_PORT:
          CURRENT_PORT = START_PORT
  
      if torch.distributed.is_available() and sys.platform not in (
          "win32",
          "cygwin",
      ):
          torch.distributed.init_process_group(
              "gloo", rank=rank, world_size=world_size
          )
  
file_path: torchmetrics/tests/unittests/conftest.py
imports: import contextlib
  import os
  import sys
  from functools import wraps
  from typing import Any, Callable, Optional
  import pytest
  import torch
  from torch.multiprocessing import Pool, set_sharing_strategy, set_start_method
label_desc: Use image node_id 1 for calling a global function with example usage: setup_ddp(rank, world_size) without return types