code: def test_out(test, reduce, dtype, device):
      src = tensor(test["src"], dtype, device)
      index = tensor(test["index"], torch.long, device)
      indptr = tensor(test["indptr"], torch.long, device)
      expected = tensor(test[reduce], dtype, device)
  
      out = torch.full_like(expected, -2)
  
      getattr(torch_scatter, "segment_" + reduce + "_csr")(
          src, indptr, out
      )
      assert torch.all(out == expected)
  
      out.fill_(-2)
  
      getattr(torch_scatter, "segment_" + reduce + "_coo")(
          src, index, out
      )
  
      if reduce == "sum" or reduce == "add":
          expected = expected - 2
      elif reduce == "mean":
          expected = out  # We can not really test this here.
      elif reduce == "min":
          expected = expected.fill_(-2)
      elif reduce == "max":
          expected[expected == 0] = -2
      else:
          raise ValueError
  
      assert torch.all(out == expected)
  
file_path: pytorch_scatter/test/test_segment.py
imports: from itertools import product
  import pytest
  import torch
  import torch_scatter
  from torch.autograd import gradcheck
  from torch_scatter.testing import devices, dtypes, reductions, tensor
label_desc: Use image node_id 3 for calling a global function with example usage: test_out(test, reduce, dtype, device) without return types