code: def test_hier_allreduce_inplace(hier_setup, dtype, dim):
      rank, size, local_rank, local_size = hier_setup
      tensor = torch.FloatTensor(*([23] * dim)).fill_(1).mul_(rank)
      name = "hier_local_allreduce_inplace_tensor_{}_{}".format(
          dim, dtype
      )
      tensor = cast_and_place(tensor, dtype)
  
      expected_value = rank - local_rank + (local_size - 1) / 2
      bf.allreduce_(
          tensor, average=True, is_hierarchical_local=True, name=name
      )
  
      assert (
          list(tensor.shape) == [23] * dim
      ), "bf.allreduce (hier_avg) produces incorrect reduced shape"
      assert (
          tensor.data - expected_value
      ).abs().max() < EPSILON, (
          "bf.allreduce (hier_avg) produces incorrect reduced tensor"
      )
  
imports: import itertools
  import os
  import numpy
  import pytest
  import torch
  import networkx
  import bluefog.torch
  from common import mpi_env_rank_and_size
label_desc: Use image node_id 8 for calling a global function with example usage: test_hier_allreduce_inplace(hier_setup, dtype, dim) without return types