code: def test_to_dense_batch(fill):
      x = torch.tensor(
          [
              [1.0, 2.0],
              [3.0, 4.0],
              [5.0, 6.0],
              [7.0, 8.0],
              [9.0, 10.0],
              [11.0, 12.0],
          ]
      )
      batch = torch.tensor([0, 0, 1, 2, 2, 2])
  
      item = fill.item() if isinstance(fill, Tensor) else fill
      expected = torch.tensor(
          [
              [[1.0, 2.0], [3.0, 4.0], [item, item]],
              [[5.0, 6.0], [item, item], [item, item]],
              [[7.0, 8.0], [9.0, 10.0], [11.0, 12.0]],
          ]
      )
  
      out, mask = to_dense_batch(x, batch, fill_value=fill)
      assert out.size() == (3, 3, 2)
      assert torch.equal(out, expected)
      assert mask.tolist() == [[1, 1, 0], [1, 0, 0], [1, 1, 1]]
  
      out, mask = to_dense_batch(
          x, batch, max_num_nodes=2, fill_value=fill
      )
      assert out.size() == (3, 2, 2)
      assert torch.equal(out, expected[:, :2])
      assert mask.tolist() == [[1, 1], [1, 0], [1, 1]]
  
      out, mask = to_dense_batch(
          x, batch, max_num_nodes=5, fill_value=fill
      )
      assert out.size() == (3, 5, 2)
      assert torch.equal(out[:, :3], expected)
      assert mask.tolist() == [
          [1, 1, 0, 0, 0],
          [1, 0, 0, 0, 0],
          [1, 1, 1, 0, 0],
      ]
  
      out, mask = to_dense_batch(x, fill_value=fill)
      assert out.size() == (1, 6, 2)
      assert torch.equal(out[0], x)
      assert mask.tolist() == [[1, 1, 1, 1, 1, 1]]
  
      out, mask = to_dense_batch(x, max_num_nodes=2, fill_value=fill)
      assert out.size() == (1, 2, 2)
      assert torch.equal(out[0], x[:2])
      assert mask.tolist() == [[1, 1]]
  
      out, mask = to_dense_batch(x, max_num_nodes=10, fill_value=fill)
      assert out.size() == (1, 10, 2)
      assert torch.equal(out[0, :6], x)
      assert mask.tolist() == [[1, 1, 1, 1, 1, 1, 0, 0, 0, 0]]
  
      out, mask = to_dense_batch(
          x, batch, batch_size=4, fill_value=fill
      )
      assert out.size() == (4, 3, 2)
  
file_path: pytorch_geometric/test/utils/test_to_dense_batch.py
imports: from typing import Tuple
  import pytest
  import torch
  from torch import Tensor
  from torch_geometric.experimental import set_experimental_mode
  from torch_geometric.testing import onlyFullTest
  from torch_geometric.utils import to_dense_batch
label_desc: Use image node_id 1 for calling a global function with example usage: test_to_dense_batch(fill) without return types