code: def test_average_forward_solution(tmp_path):
      """Test averaging forward solutions."""
      fwd = read_forward_solution(fname_meeg)
      # input not a list
      pytest.raises(TypeError, average_forward_solutions, 1)
      # list is too short
      pytest.raises(ValueError, average_forward_solutions, [])
      # negative weights
      pytest.raises(
          ValueError, average_forward_solutions, [fwd, fwd], [-1, 0]
      )
      # all zero weights
      pytest.raises(
          ValueError, average_forward_solutions, [fwd, fwd], [0, 0]
      )
      # weights not same length
      pytest.raises(
          ValueError, average_forward_solutions, [fwd, fwd], [0, 0, 0]
      )
      # list does not only have all dict()
      pytest.raises(TypeError, average_forward_solutions, [1, fwd])
  
      # try an easy case
      fwd_copy = average_forward_solutions([fwd])
      assert isinstance(fwd_copy, Forward)
      assert_array_equal(fwd["sol"]["data"], fwd_copy["sol"]["data"])
  
      # modify a fwd solution, save it, use MNE to average with old one
      fwd_copy["sol"]["data"] *= 0.5
      fname_copy = str(tmp_path / "copy-fwd.fif")
      write_forward_solution(fname_copy, fwd_copy, overwrite=True)
      cmd = (
          "mne_average_forward_solutions",
          "--fwd",
          fname_meeg,
          "--fwd",
          fname_copy,
          "--out",
          fname_copy,
      )
      run_subprocess(cmd)
  
      # now let's actually do it, with one filename and one fwd
      fwd_ave = average_forward_solutions([fwd, fwd_copy])
      assert_array_equal(
          0.75 * fwd["sol"]["data"], fwd_ave["sol"]["data"]
      )
      # fwd_ave_mne = read_forward_solution(fname_copy)
      # assert_array_equal(fwd_ave_mne['sol']['data'], fwd_ave['sol']['data'])
  
      # with gradient
      fwd = read_forward_solution(fname_meeg_grad)
      fwd_ave = average_forward_solutions([fwd, fwd])
      assert_forward_allclose(fwd, fwd_ave)
  
imports: import gc
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import SourceEstimate, VectorSourceEstimate, apply_forward, apply_forward_raw, average_forward_solutions, convert_forward_solution, pick_types_forward, read_evokeds, read_forward_solution, write_forward_solution
  from mne._fiff.pick import pick_channels_forward
  from mne.channels import equalize_channels
  from mne.datasets import testing
  from mne.forward import Forward, compute_depth_prior, compute_orient_prior, is_fixed_orient, restrict_forward_to_label, restrict_forward_to_stc
  from mne.io import read_info
  from mne.label import read_label
  from mne.utils import requires_mne, run_subprocess
label_desc: Use image node_id 8 for calling a global function with example usage: test_average_forward_solution(tmp_path) without return types