code: def transform(instance, max_seq_length):
      """Transform instance to inputs for MLM and NSP."""
      input_ids = instance.tokens
      assert len(input_ids) <= max_seq_length
      segment_ids = instance.segment_ids
      masked_lm_positions = instance.masked_lm_positions
      valid_lengths = len(input_ids)
  
      masked_lm_ids = instance.masked_lm_labels
      masked_lm_weights = [1.0] * len(masked_lm_ids)
  
      next_sentence_label = 1 if instance.is_random_next else 0
  
      features = {}
      features["input_ids"] = input_ids
      features["segment_ids"] = segment_ids
      features["masked_lm_positions"] = masked_lm_positions
      features["masked_lm_ids"] = masked_lm_ids
      features["masked_lm_weights"] = masked_lm_weights
      features["next_sentence_labels"] = [next_sentence_label]
      features["valid_lengths"] = [valid_lengths]
      return features
  
imports: import argparse
  import logging
  import io
  import os
  import glob
  import collections
  import warnings
  import random
  import time
  from multiprocessing import Pool
  import numpy
  from gluonnlp.models.bert import BertModel, BertForPretrain, get_pretrained_bert
  import gluonnlp
label_desc: Use image node_id 1 for calling a global function with example usage: transform(instance, max_seq_length) and returns: features