code: def test_partial_dependency_grid(hspace):
      """Test the computation of the averages and stds"""
  
      flattened_space = flatten_space(hspace)
  
      n_points = 5
      n_samples = 20
      samples = [
          format_trials.trial_to_tuple(trial, flattened_space)
          for trial in flattened_space.sample(n_samples)
      ]
      samples = pd.DataFrame(samples, columns=flattened_space.keys())
  
      params = ["x", "y[0]", "y[2]", "z"]
  
      # Test for 1 param
      grid, averages, stds = partial_dependency_grid(
          flattened_space,
          mock_model(),
          ["x"],
          samples,
          n_points=n_points,
      )
  
      assert list(grid.keys()) == ["x"]
      assert list(grid["x"]) == [0, 1.5, 3, 4.5, 6]
      assert averages.shape == (n_points,)
      assert stds.shape == (n_points,)
      assert averages[0] == numpy.arange(n_samples).mean()
      assert (
          averages[4]
          == numpy.arange(
              n_samples * (n_points - 1), n_samples * n_points
          ).mean()
      )
      assert stds[0] == numpy.arange(n_samples).std()
  
      # Test for 2 param
      grid, averages, stds = partial_dependency_grid(
          flattened_space,
          mock_model(),
          ["x", "y[0]"],
          samples,
          n_points=n_points,
      )
  
      assert list(grid.keys()) == ["x", "y[0]"]
      assert list(grid["x"]) == [0, 1.5, 3, 4.5, 6]
      # assert list(grid["y[0]"]) == [0, 0.75, 1.5, 2.25, 3]
      numpy.testing.assert_almost_equal(
          grid["y[0]"],
          numpy.linspace(
              numpy.log(float(f"{numpy.e}")),
              numpy.log(float(f"{numpy.e}") ** 4),
              num=n_points,
          ),
          decimal=4,
      )
  
      assert averages.shape == (n_points, n_points)
      assert stds.shape == (n_points, n_points)
      assert averages[0, 0] == numpy.arange(n_samples).mean()
      assert (
          averages[4, 4]
          == numpy.arange(
              n_samples * n_points * n_points - n_samples,
              n_samples * n_points * n_points,
          ).mean()
      )
      assert stds[0, 0] == numpy.arange(n_samples).std()
      assert stds[4, 4] == numpy.arange(n_samples).std()
  
      # Test for 2 param with one categorical, with less categories then n_points
      grid, averages, stds = partial_dependency_grid(
          flattened_space,
          mock_model(),
          ["x", "z"],
          samples,
          n_points=n_points,
      )
  
      assert list(grid.keys()) == ["x", "z"]
      assert list(grid["x"]) == [0, 1.5, 3, 4.5, 6]
      assert list(grid["z"]) == [0, 1, 2]
      assert averages.shape == (3, n_points)
      assert stds.shape == (3, n_points)
  
      assert averages[0, 0] == numpy.arange(n_samples).mean()
      assert (
          averages[2, 4]
          == numpy.arange(
              n_samples * 3 * n_points - n_samples,
              n_samples * 3 * n_points,
          ).mean()
      )
      assert stds[0, 0] == numpy.arange(n_samples).std()
      assert stds[2, 4] == numpy.arange(n_samples).std()
  
imports: import copy
  import numpy
  import pandas
  import pytest
  from orion.analysis.partial_dependency_utils import make_grid, partial_dependency, partial_dependency_grid, reverse
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.utils import format_trials
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 9 for calling a global function with example usage: test_partial_dependency_grid(hspace) without return types