code: def test_dynamic_partition():
      data = torch.Tensor([10, 20, 30, 40, 50])
      partitions = torch.Tensor([0, 0, 1, 1, 0])
  
      partitioned_data = metric_utils.dynamic_partition(
          data, partitions, 2
      )
  
      assert torch.equal(
          partitioned_data[0], torch.Tensor([10.0, 20.0, 50.0])
      )
      assert torch.equal(
          partitioned_data[1], torch.Tensor([30.0, 40.0])
      )
  
file_path: ludwig/tests/ludwig/utils/test_metric_utils.py
imports: from collections import OrderedDict
  import torch
  from ludwig.utils import metric_utils
  from ludwig.utils.metric_utils import TrainerMetric
label_desc: Use image node_id 1 for calling a global function with example usage: test_dynamic_partition() without return types