code: def assign_textual_node_features(ndata, textset, ntype):
      """
      Assigns numericalized tokens from a torchtext dataset to given block.
  
      The numericalized tokens would be stored in the block as node features
      with the same name as ``field_name``.
  
      The length would be stored as another node feature with name
      ``field_name + '__len'``.
  
      block : DGLGraph
          First element of the compacted blocks, with "dgl.NID" as the
          corresponding node ID in the original graph, hence the index to the
          text dataset.
  
          The numericalized tokens (and lengths if available) would be stored
          onto the blocks as new node features.
      textset : torchtext.data.Dataset
          A torchtext dataset whose number of examples is the same as that
          of nodes in the original graph.
      """
      node_ids = ndata[dgl.NID].numpy()
  
      for field_name, field in textset.items():
          textlist, vocab, pad_var, batch_first = field
  
          examples = [textlist[i] for i in node_ids]
          ids_iter = numericalize_tokens_from_iterator(vocab, examples)
  
          maxsize = max([len(textlist[i]) for i in node_ids])
          ids = next(ids_iter)
          x = torch.asarray([num for num in ids])
          lengths = torch.tensor([len(x)])
          tokens = padding(x, maxsize, pad_var)
  
          for ids in ids_iter:
              x = torch.asarray([num for num in ids])
              l = torch.tensor([len(x)])
              y = padding(x, maxsize, pad_var)
              tokens = torch.vstack((tokens, y))
              lengths = torch.cat((lengths, l))
  
          if not batch_first:
              tokens = tokens.t()
  
          ndata[field_name] = tokens
          ndata[field_name + "__len"] = lengths
  
imports: import dgl
  import numpy
  import torch
  from torch.utils.data import DataLoader, IterableDataset
  from torchtext.data.functional import numericalize_tokens_from_iterator
label_desc: Use image node_id 4 for calling a global function with example usage: assign_textual_node_features(ndata, textset, ntype) without return types