code: def filter_data(
      model_name, data, tokenizer=None, log_level=logging.DEBUG
  ):
      """
      Filter out the (NER, POS) data that is too long for BERT model.
      """
      if tokenizer is None:
          tokenizer = load_tokenizer(model_name)
      filtered_data = []
      # eliminate all the sentences that are too long for bert model
      for sent in data:
          sentence = [
              word if isinstance(word, str) else word[0]
              for word in sent
          ]
          _, tokenized_sent = tokenize_manual(
              model_name, sentence, tokenizer
          )
  
          if len(tokenized_sent) > tokenizer.model_max_length - 2:
              continue
  
          filtered_data.append(sent)
  
      logger.log(
          log_level,
          "Eliminated %d of %d datapoints because their length is over maximum size of BERT model.",
          (len(data) - len(filtered_data)),
          len(data),
      )
  
      return filtered_data
  
imports: import math
  import logging
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence, pack_sequence, PackedSequence
label_desc: Use image node_id 5 for calling a global function with example usage: filter_data(model_name, data, tokenizer, log_level) and returns: filtered_data