code: def test_gradient_aggregation_parallel(self, tmp_path: pathlib.Path):
      launch_config = pytorch_utils.setup_torch_distributed()
  
      val_metrics = launcher.elastic_launch(
          launch_config, run_identity
      )(tmp_path)
  
      # weights returned by both models are the same.
      model_1_metrics = val_metrics[0]
      model_1_weights = [
          model_1_metrics[i]["weight"]
          for i in range(len(model_1_metrics))
      ]
      model_2_metrics = val_metrics[1]
      model_2_weights = [
          model_2_metrics[i]["weight"]
          for i in range(len(model_2_metrics))
      ]
  
      expected_weights = calculate_gradients(num_epochs=1)
  
      assert model_1_weights == pytest.approx(
          expected_weights
      ), f"{model_1_weights} != {expected_weights}"
  
      assert model_2_weights == pytest.approx(
          expected_weights
      ), f"{model_2_weights} != {expected_weights}"
  
imports: import contextlib
  import importlib
  import io
  import os
  import pathlib
  import sys
  import typing
  from unittest import mock
  import numpy
  import pytest
  import torch
  from _pytest import monkeypatch
  from torch.distributed import launcher
  import determined
  from determined import pytorch
  from tests.experiment import pytorch_utils, utils
  from tests.experiment.fixtures import pytorch_onevar_model
label_desc: Use image node_id 27 for calling the TestPyTorchTrial obj's underlying member method code with example usage: obj.test_gradient_aggregation_parallel(tmp_path) without return types