code: def test_tree_get_marginalized_statistics(
      tree: _FanovaTree,
      feature_vector: List[float],
      expected: List[Tuple[NodeIndex, Cardinality]],
      expected_tree_statistics: List[Dict[str, List]],
  ) -> None:
      value, weight = tree._get_marginalized_statistics(
          numpy.array(feature_vector)
      )
  
      expected_values = []
      expected_weights = []
  
      for node_index, cardinality in expected:
          expected_statistics = expected_tree_statistics[node_index]
          expected_values.append(expected_statistics["values"])
          expected_weights.append(
              [w / cardinality for w in expected_statistics["weights"]]
          )
  
      expected_value = numpy.average(
          expected_values, weights=expected_weights
      )
      expected_weight = numpy.sum(expected_weights)
  
      assert math.isclose(value, expected_value)
      assert math.isclose(weight, expected_weight)
  
file_path: optuna/tests/importance_tests/fanova_tests/test_tree.py
imports: import math
  from typing import Dict
  from typing import List
  from typing import Tuple
  from unittest.mock import Mock
  import numpy
  import pytest
  from optuna.importance._fanova._tree import _FanovaTree
label_desc: Use image node_id 5 for calling a global function with example usage: test_tree_get_marginalized_statistics(tree, feature_vector, expected, expected_tree_statistics) without return types