code: def test_multi_range_advanced(client):
      client.ts().create(1, labels={"Test": "This", "team": "ny"})
      client.ts().create(
          2, labels={"Test": "This", "Taste": "That", "team": "sf"}
      )
      for i in range(100):
          client.ts().add(1, i, i % 7)
          client.ts().add(2, i, i % 11)
  
      # test with selected labels
      res = client.ts().mrange(
          0, 200, filters=["Test=This"], select_labels=["team"]
      )
      if is_resp2_connection(client):
          assert {"team": "ny"} == res[0]["1"][0]
          assert {"team": "sf"} == res[1]["2"][0]
  
          # test with filterby
          res = client.ts().mrange(
              0,
              200,
              filters=["Test=This"],
              filter_by_ts=[i for i in range(10, 20)],
              filter_by_min_value=1,
              filter_by_max_value=2,
          )
          assert [(15, 1.0), (16, 2.0)] == res[0]["1"][1]
  
          # test groupby
          res = client.ts().mrange(
              0, 3, filters=["Test=This"], groupby="Test", reduce="sum"
          )
          assert [(0, 0.0), (1, 2.0), (2, 4.0), (3, 6.0)] == res[0][
              "Test=This"
          ][1]
          res = client.ts().mrange(
              0, 3, filters=["Test=This"], groupby="Test", reduce="max"
          )
          assert [(0, 0.0), (1, 1.0), (2, 2.0), (3, 3.0)] == res[0][
              "Test=This"
          ][1]
          res = client.ts().mrange(
              0, 3, filters=["Test=This"], groupby="team", reduce="min"
          )
          assert 2 == len(res)
          assert [(0, 0.0), (1, 1.0), (2, 2.0), (3, 3.0)] == res[0][
              "team=ny"
          ][1]
          assert [(0, 0.0), (1, 1.0), (2, 2.0), (3, 3.0)] == res[1][
              "team=sf"
          ][1]
  
          # test align
          res = client.ts().mrange(
              0,
              10,
              filters=["team=ny"],
              aggregation_type="count",
              bucket_size_msec=10,
              align="-",
          )
          assert [(0, 10.0), (10, 1.0)] == res[0]["1"][1]
          res = client.ts().mrange(
              0,
              10,
              filters=["team=ny"],
              aggregation_type="count",
              bucket_size_msec=10,
              align=5,
          )
          assert [(0, 5.0), (5, 6.0)] == res[0]["1"][1]
      else:
          assert {"team": "ny"} == res["1"][0]
          assert {"team": "sf"} == res["2"][0]
  
          # test with filterby
          res = client.ts().mrange(
              0,
              200,
              filters=["Test=This"],
              filter_by_ts=[i for i in range(10, 20)],
              filter_by_min_value=1,
              filter_by_max_value=2,
          )
          assert [[15, 1.0], [16, 2.0]] == res["1"][2]
  
          # test groupby
          res = client.ts().mrange(
              0, 3, filters=["Test=This"], groupby="Test", reduce="sum"
          )
          assert [[0, 0.0], [1, 2.0], [2, 4.0], [3, 6.0]] == res[
              "Test=This"
          ][3]
          res = client.ts().mrange(
              0, 3, filters=["Test=This"], groupby="Test", reduce="max"
          )
          assert [[0, 0.0], [1, 1.0], [2, 2.0], [3, 3.0]] == res[
              "Test=This"
          ][3]
          res = client.ts().mrange(
              0, 3, filters=["Test=This"], groupby="team", reduce="min"
          )
          assert 2 == len(res)
          assert [[0, 0.0], [1, 1.0], [2, 2.0], [3, 3.0]] == res[
              "team=ny"
          ][3]
          assert [[0, 0.0], [1, 1.0], [2, 2.0], [3, 3.0]] == res[
              "team=sf"
          ][3]
  
          # test align
          res = client.ts().mrange(
              0,
              10,
              filters=["team=ny"],
              aggregation_type="count",
              bucket_size_msec=10,
              align="-",
          )
          assert [[0, 10.0], [10, 1.0]] == res["1"][2]
          res = client.ts().mrange(
              0,
              10,
              filters=["team=ny"],
              aggregation_type="count",
              bucket_size_msec=10,
              align=5,
          )
          assert [[0, 5.0], [5, 6.0]] == res["1"][2]
  
imports: import math
  import time
  from time import sleep
  import pytest
  import redis
  from .conftest import assert_resp_response, is_resp2_connection, skip_ifmodversion_lt
label_desc: Use image node_id 22 for calling a global function with example usage: test_multi_range_advanced(client) without return types