docstr: Tags the mention, trims the context and concatenates everything to form the context representation
docstr_tok: ["Tags","the","mention",",","trims","the","context","and","concatenates","everything","to","form","the","context","representation"]
code: def _get_context_token_representation(
      context_key,
      sample,
      tokenizer,
      max_sub_seq_length,
      start_token,
      end_token,
      mention_text_key="text",
      tagged=True,
  ):
      """Tags the mention, trims the context and concatenates everything to form the context representation"""
      mention_tokens = (
          [start_token]
          + tokenizer.tokenize(sample[mention_text_key])
          + [end_token]
      )
  
      max_sub_seq_length = (
          max_sub_seq_length - len(mention_tokens)
      ) // 2
  
      context_left, context_right = sample[context_key]
      context_left = tokenizer.tokenize(context_left)
      context_right = tokenizer.tokenize(context_right)
      if len(context_left) > max_sub_seq_length:
          context_left = context_left[-max_sub_seq_length:]
      if len(context_right) > max_sub_seq_length:
          context_right = context_right[:max_sub_seq_length]
  
      context_tokens = context_left + mention_tokens + context_right
  
      return context_tokens
  
imports: import torch
  import os
  import numpy
  from pytorch_transformers.modeling_bert import BertPreTrainedModel, BertConfig, BertModel
  from pytorch_transformers.tokenization_bert import BertTokenizer
  from torch.utils.data import DataLoader, SequentialSampler, TensorDataset
  from torch import nn
  from torch.nn import CrossEntropyLoss, MSELoss
  from tqdm import tqdm
  from pytorch_transformers.optimization import AdamW, WarmupLinearSchedule
  from pytorch_transformers.file_utils import PYTORCH_PRETRAINED_BERT_CACHE
label_desc: Use image node_id 9 for calling the BertReranker obj's underlying member method code with example usage: obj._get_context_token_representation(context_key, sample, tokenizer, max_sub_seq_length, start_token, end_token, mention_text_key, tagged) and returns: context_tokens