code: def test_recursive_detach():
      device = "cuda" if torch.cuda.is_available() else "cpu"
      x = {
          "foo": torch.tensor(0, device=device),
          "bar": {
              "baz": torch.tensor(
                  1.0, device=device, requires_grad=True
              )
          },
      }
      y = recursive_detach(x, to_cpu=True)
  
      assert x["foo"].device.type == device
      assert x["bar"]["baz"].device.type == device
      assert x["bar"]["baz"].requires_grad
  
      assert y["foo"].device.type == "cpu"
      assert y["bar"]["baz"].device.type == "cpu"
      assert not y["bar"]["baz"].requires_grad
  
label_desc: Use image node_id 1 for calling a global function with example usage: test_recursive_detach() without return types