code: def test_arrtrim_dollar(client):
      client.json().set(
          "doc1",
          "$",
          {
              "a": ["foo"],
              "nested1": {"a": ["hello", None, "world"]},
              "nested2": {"a": 31},
          },
      )
      # Test multi
      assert client.json().arrtrim("doc1", "$..a", "1", -1) == [
          0,
          2,
          None,
      ]
      res = [
          {
              "a": [],
              "nested1": {"a": [None, "world"]},
              "nested2": {"a": 31},
          }
      ]
      assert_resp_response(
          client, client.json().get("doc1", "$"), res, [res]
      )
  
      assert client.json().arrtrim("doc1", "$..a", "1", "1") == [
          0,
          1,
          None,
      ]
      res = [
          {"a": [], "nested1": {"a": ["world"]}, "nested2": {"a": 31}}
      ]
      assert_resp_response(
          client, client.json().get("doc1", "$"), res, [res]
      )
  
      # Test single
      assert client.json().arrtrim("doc1", "$.nested1.a", 1, 0) == [0]
      res = [{"a": [], "nested1": {"a": []}, "nested2": {"a": 31}}]
      assert_resp_response(
          client, client.json().get("doc1", "$"), res, [res]
      )
  
      # Test missing key
      with pytest.raises(exceptions.ResponseError):
          client.json().arrtrim("non_existing_doc", "..a", "0", 1)
  
      # Test legacy
      client.json().set(
          "doc1",
          "$",
          {
              "a": ["foo"],
              "nested1": {"a": ["hello", None, "world"]},
              "nested2": {"a": 31},
          },
      )
  
      # Test multi (all paths are updated, but return result of last path)
      assert client.json().arrtrim("doc1", "..a", "1", "-1") == 2
  
      # Test single
      assert client.json().arrtrim("doc1", ".nested1.a", "1", "1") == 1
      res = [
          {"a": [], "nested1": {"a": ["world"]}, "nested2": {"a": 31}}
      ]
      assert_resp_response(
          client, client.json().get("doc1", "$"), res, [res]
      )
  
      # Test missing key
      with pytest.raises(exceptions.ResponseError):
          client.json().arrtrim("non_existing_doc", "..a", 1, 1)
  
imports: import pytest
  import redis
  from redis import Redis, exceptions
  from redis.commands.json.decoders import decode_list, unstring
  from redis.commands.json.path import Path
  from .conftest import _get_client, assert_resp_response, skip_ifmodversion_lt
label_desc: Use image node_id 38 for calling a global function with example usage: test_arrtrim_dollar(client) without return types