code: def main():
      global WORD
      WORD = data.Field(
          include_lengths=True,
          batch_first=True,
          eos_token=None,
          init_token=None,
      )
      LABEL = data.Field(sequential=False, batch_first=True)
      TREE = data.RawField(
          postprocessing=ListOpsDataset.tree_field(WORD)
      )
      TREE.is_target = False
      train = ListOpsDataset(
          "data/train_d20s.tsv",
          (("word", WORD), ("label", LABEL), ("tree", TREE)),
          filter_pred=lambda x: 5 < len(x.word) < config["train_len"],
      )
      WORD.build_vocab(train)
      LABEL.build_vocab(train)
      valid = ListOpsDataset(
          "data/test_d20s.tsv",
          (("word", WORD), ("label", LABEL), ("tree", TREE)),
          filter_pred=lambda x: 5 < len(x.word) < 150,
      )
  
      train_iter = TokenBucket(
          train,
          batch_size=1500,
          device="cuda:0",
          key=lambda x: len(x.word),
      )
      train_iter.repeat = False
      valid_iter = data.BucketIterator(
          train, batch_size=50, train=False, sort=False, device="cuda:0"
      )
  
      NT = 1
      T = len(WORD.vocab)
      V = T
  
      if True:
          tree_lstm = TreeLSTM(
              config["H"], len(WORD.vocab) + 100, len(LABEL.vocab)
          ).cuda()
          for p in tree_lstm.parameters():
              if p.dim() > 1:
                  torch.nn.init.xavier_uniform_(p)
  
          model = SpanLSTM(NT, len(WORD.vocab), config["H"]).cuda()
          for p in model.parameters():
              if p.dim() > 1:
                  torch.nn.init.xavier_uniform_(p)
  
          wandb.watch((model, tree_lstm))
          print(wandb.config)
          tree = run_train(train_iter, valid_iter, model, tree_lstm, V)
      else:
          print("loading")
          model, tree_lstm = torch.load("cp.yoyo.model")
          print(valid_sup(valid_iter, model, tree_lstm, V))
  
file_path: pytorch-struct/examples/tree.py
imports: from torch_struct import TreeCRF, SelfCritical
  import torchtext.data
  from torch_struct.data import ListOpsDataset, TokenBucket
  from torch_struct.networks import TreeLSTM, SpanLSTM
  import torch
  import torch.nn
  import wandb
label_desc: Use image node_id 6 for calling a global function with example usage: main() without return types