code: def convert_single_example(
      ex_index,
      example,
      max_seq_length,
      tokenizer,
      label_length=1,
      do_mask=True,
      max_predictions_per_seq=10,
  ):
      """Converts a single `InputExample` into a single `InputFeatures`."""
  
      # This will only be for testing so OK
      if isinstance(example, PaddingInputExample):
          return InputFeatures(
              input_ids=[[0] * max_seq_length] * label_length,
              input_mask=[[0] * max_seq_length] * label_length,
              segment_ids=[[0] * max_seq_length] * label_length,
              label_id=0,
              masked_lm_positions=[[0] * max_predictions_per_seq]
              * label_length,
              masked_lm_ids=[[0] * max_predictions_per_seq]
              * label_length,
              masked_lm_weights=[[0.0] * max_predictions_per_seq]
              * label_length,
              is_real_example=False,
          )
  
      tokens_bs = [tokenizer.tokenize(tb) for tb in example.text_b]
      if example.text_a:
          tokens_a = tokenizer.tokenize(example.text_a)
          tokens_as = [
              [x for x in tokens_a] for i in range(len(tokens_bs))
          ]
  
          for i in range(len(tokens_bs)):
              _truncate_seq_pair(
                  tokens_as[i], tokens_bs[i], max_seq_length - 3
              )
  
          (
              input_ids,
              input_mask,
              segment_ids,
              masked_lm_positions,
              masked_lm_ids,
              masked_lm_weights,
              tokens,
          ) = zip(
              *[
                  bert_pad(
                      token_a,
                      token_b,
                      max_seq_length,
                      tokenizer,
                      do_mask=do_mask,
                      max_predictions_per_seq=max_predictions_per_seq,
                  )
                  for token_a, token_b in zip(tokens_as, tokens_bs)
              ]
          )
  
      else:
          tokens_bs = [x[-(max_seq_length - 2) :] for x in tokens_bs]
  
          (
              input_ids,
              input_mask,
              segment_ids,
              masked_lm_positions,
              masked_lm_ids,
              masked_lm_weights,
              tokens,
          ) = zip(
              *[
                  bert_pad(
                      token_b,
                      None,
                      max_seq_length,
                      tokenizer,
                      do_mask=do_mask,
                      max_predictions_per_seq=max_predictions_per_seq,
                  )
                  for token_b in tokens_bs
              ]
          )
      if not do_mask:
          masked_lm_positions, masked_lm_ids, masked_lm_weights = (
              None,
              None,
              None,
          )
  
      if ex_index < 5:
          tf.logging.info("*** Example ***")
          tf.logging.info("guid: %s" % (example.guid))
          tf.logging.info(
              "label: %s (id = %d)" % (example.label, example.label)
          )
  
          for i, these_tokens in enumerate(tokens):
              tf.logging.info("Ending: {} / {}".format(i, len(tokens)))
              tf.logging.info(
                  "tokens: {}".format(
                      " ".join(
                          [
                              tokenization.printable_text(x)
                              for x in these_tokens
                          ]
                      )
                  )
              )
              tf.logging.info(
                  "input_ids: %s"
                  % " ".join([str(x) for x in input_ids[i]])
              )
              tf.logging.info(
                  "input_mask: %s"
                  % " ".join([str(x) for x in input_mask[i]])
              )
              tf.logging.info(
                  "segment_ids: %s"
                  % " ".join([str(x) for x in segment_ids[i]])
              )
              if do_mask:
                  tf.logging.info(
                      "masked_lm_positions: %s"
                      % " ".join(
                          [str(x) for x in masked_lm_positions[i]]
                      )
                  )
                  tf.logging.info(
                      "masked_lm_ids: %s"
                      % " ".join([str(x) for x in masked_lm_ids[i]])
                  )
                  tf.logging.info(
                      "masked_lm_weights: %s"
                      % " ".join([str(x) for x in masked_lm_weights[i]])
                  )
  
      assert len(input_ids) == label_length
  
      feature = InputFeatures(
          input_ids=input_ids,
          input_mask=input_mask,
          segment_ids=segment_ids,
          label_id=example.label,
          masked_lm_positions=masked_lm_positions,
          masked_lm_ids=masked_lm_ids,
          masked_lm_weights=masked_lm_weights,
          is_real_example=True,
      )
      return feature
  
imports: import collections
  import csv
  import os
  import zipfile
  import requests
  import tensorflow
  from adversarial_filtering.bert import modeling
  from adversarial_filtering.bert import tokenization
  import random
  import gcsfs
  import numpy
  from tensorflow.python.lib.io import file_io
label_desc: Use image node_id 7 for calling a global function with example usage: convert_single_example(ex_index, example, max_seq_length, tokenizer, label_length, do_mask, max_predictions_per_seq) and returns: feature, InputFeatures