code: def test_search_aligned_metrics_api(self):
      client = self.client
      run_hashes = []
      for run, _ in zip(self.repo.iter_runs(), range(2)):
          run_hashes.append(run.hash)
  
      response = client.post(
          "/api/runs/search/metric/align/",
          json={
              "align_by": "accuracy",
              "runs": [
                  {
                      "run_id": run_hashes[0],
                      "traces": [
                          {
                              "name": "loss",
                              "slice": [0, 0, 100],
                              "context": {"is_training": False},
                          }
                      ],
                  },
                  {
                      "run_id": run_hashes[1],
                      "traces": [
                          {
                              "name": "loss",
                              "slice": [0, 0, 100],
                              "context": {
                                  "is_training": True,
                                  "subset": "train",
                              },
                          }
                      ],
                  },
              ],
          },
      )
      self.assertEqual(200, response.status_code)
  
      decoded_response = decode_tree(
          decode_encoded_tree_stream(
              response.iter_bytes(chunk_size=512 * 1024)
          )
      )
      self.assertEqual(2, len(decoded_response))
      self.assertListEqual(run_hashes, list(decoded_response.keys()))
      self.assertEqual([], decoded_response[run_hashes[1]])
      traces = decoded_response[run_hashes[0]][0]
      self.assertEqual("loss", traces["name"])
      self.assertDictEqual({"is_training": False}, traces["context"])
      self.assertEqual(99, traces["x_axis_values"]["shape"])
  
imports: import pytest
  import numpy
  from parameterized import parameterized
  from tests.base import PrefilledDataApiTestBase, ApiTestBase
  from tests.utils import decode_encoded_tree_stream
  from aim.storage.treeutils import decode_tree
  from aim.sdk.run import Run
label_desc: Use image node_id 5 for calling the TestRunApi obj's underlying member method code with example usage: obj.test_search_aligned_metrics_api() without return types