code: def test_to_nested_tensor():
      x = torch.randn(5, 4, 3)
  
      out = to_nested_tensor(x, batch=torch.tensor([0, 0, 1, 1, 1]))
      out = out.to_padded_tensor(padding=0)
      assert out.size() == (2, 3, 4, 3)
      assert torch.allclose(out[0, :2], x[0:2])
      assert torch.allclose(out[1, :3], x[2:5])
  
      out = to_nested_tensor(x, ptr=torch.tensor([0, 2, 5]))
      out = out.to_padded_tensor(padding=0)
      assert out.size() == (2, 3, 4, 3)
      assert torch.allclose(out[0, :2], x[0:2])
      assert torch.allclose(out[1, :3], x[2:5])
  
      out = to_nested_tensor(x)
      out = out.to_padded_tensor(padding=0)
      assert out.size() == (1, 5, 4, 3)
      assert torch.allclose(out[0], x)
  
imports: import pytest
  import torch
  from torch_geometric.testing import withPackage
  from torch_geometric.utils import from_nested_tensor, to_nested_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: test_to_nested_tensor() without return types