code: import torch
  from torch_sparse import SparseTensor
  
  from torch_geometric.nn import FiLMConv
  
  
  def test_film_conv():
      x1 = torch.randn(4, 4)
      x2 = torch.randn(2, 16)
      edge_index = torch.tensor([[0, 1, 1, 2, 2, 3], [0, 0, 1, 0, 1, 1]])
      edge_type = torch.tensor([0, 1, 1, 0, 0, 1])
      row, col = edge_index
      adj = SparseTensor(row=row, col=col, value=edge_type, sparse_sizes=(4, 4))
  
      conv = FiLMConv(4, 32)
      assert conv.__repr__() == 'FiLMConv(4, 32, num_relations=1)'
      out1 = conv(x1, edge_index)
      assert out1.size() == (4, 32)
      assert conv(x1, adj.t().set_value(None)).tolist() == out1.tolist()
  
      t = '(Tensor, Tensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit(x1, edge_index).tolist() == out1.tolist()
      t = '(Tensor, SparseTensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit(x1, adj.t().set_value(None)).tolist() == out1.tolist()
  
      conv = FiLMConv(4, 32, num_relations=2)
      assert conv.__repr__() == 'FiLMConv(4, 32, num_relations=2)'
      out1 = conv(x1, edge_index, edge_type)
      assert out1.size() == (4, 32)
      assert conv(x1, adj.t()).tolist() == out1.tolist()
  
      t = '(Tensor, Tensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit(x1, edge_index, edge_type).tolist() == out1.tolist()
      t = '(Tensor, SparseTensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit(x1, adj.t()).tolist() == out1.tolist()
  
      adj = adj.sparse_resize((4, 2))
  
      conv = FiLMConv((4, 16), 32)
      assert conv.__repr__() == 'FiLMConv((4, 16), 32, num_relations=1)'
      out1 = conv((x1, x2), edge_index)
      assert out1.size() == (2, 32)
      assert conv((x1, x2), adj.t().set_value(None)).tolist() == out1.tolist()
  
      t = '(PairTensor, Tensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit((x1, x2), edge_index).tolist() == out1.tolist()
      t = '(PairTensor, SparseTensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit((x1, x2), adj.t().set_value(None)).tolist() == out1.tolist()
  
      conv = FiLMConv((4, 16), 32, num_relations=2)
      assert conv.__repr__() == 'FiLMConv((4, 16), 32, num_relations=2)'
      out1 = conv((x1, x2), edge_index, edge_type)
      assert out1.size() == (2, 32)
      assert conv((x1, x2), adj.t()).tolist() == out1.tolist()
  
      t = '(PairTensor, Tensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit((x1, x2), edge_index, edge_type).tolist() == out1.tolist()
      t = '(PairTensor, SparseTensor, OptTensor) -> Tensor'
      jit = torch.jit.script(conv.jittable(t))
      assert jit((x1, x2), adj.t()).tolist() == out1.tolist()
   import re
  
  import torch
  
  from torch_geometric.transforms import BaseTransform
  from torch_geometric.utils import remove_isolated_nodes
  
  
  class RemoveIsolatedNodes(BaseTransform):
      r"""Removes isolated nodes from the graph."""
      def __call__(self, data):
          num_nodes = data.num_nodes
          out = remove_isolated_nodes(data.edge_index, data.edge_attr, num_nodes)
          data.edge_index, data.edge_attr, mask = out
  
          if hasattr(data, '__num_nodes__'):
              data.num_nodes = int(mask.sum())
  
          for key, item in data:
              if bool(re.search('edge', key)):
                  continue
              if torch.is_tensor(item) and item.size(0) == num_nodes:
                  data[key] = item[mask]
  
          return data
  
apis: torch.randn torch.tensor
apis: torch.is_tensor