docstr: Generate the representation given the inputs.
  
  This is used for pre-training or fine-tuning a bert model.
  Get the first token of the whole sequence which is [CLS]
  
  sequence
      - layout = 'NT'
          Shape (batch_size, sequence_length, units)
      - layout = 'TN'
          Shape (sequence_length, batch_size, units)
  return:
      Shape (batch_size, units)
docstr_tok: ["Generate","the","representation","given","the","inputs",".","This","is","used","for","pre-training","or","fine-tuning","a","bert","model",".","Get","the","first","token","of","the","whole","sequence","which","is","[","CLS","]","sequence","-","layout","=","'NT'","Shape","(","batch_size",",","sequence_length",",","units",")","-","layout","=","'TN'","Shape","(","sequence_length",",","batch_size",",","units",")","return",":","Shape","(","batch_size",",","units",")"]
code: def apply_pooling(self, sequence):
      """Generate the representation given the inputs.
  
      This is used for pre-training or fine-tuning a bert model.
      Get the first token of the whole sequence which is [CLS]
  
      sequence
          - layout = 'NT'
              Shape (batch_size, sequence_length, units)
          - layout = 'TN'
              Shape (sequence_length, batch_size, units)
      return:
          Shape (batch_size, units)
      """
      if self.layout == "NT":
          outputs = sequence[:, 0, :]
      else:
          outputs = sequence[0, :, :]
      return th.tanh(self.pooler(outputs))
  
imports: import logging
  import torch
  from ..attention_cell import gen_self_attn_mask
  from .transformer import TransformerEncoderLayer
  from ..layers import get_activation, sequence_mask
  from ...utils.registry import Registry
  from ...models.bert import bert_cfg_reg
label_desc: Use image node_id 5 for calling the BertModel obj's underlying member method code with example usage: obj.apply_pooling(sequence) and returns: th