class_docstr: A transformer model. User is able to modify the attributes as needed. The architechture
  is based on the paper "Attention Is All You Need". Ashish Vaswani, Noam Shazeer,
  Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and
  Illia Polosukhin. 2017. Attention is all you need. In Advances in Neural Information
  Processing Systems, pages 6000-6010.
  
  Args:
      d_model: the number of expected features in the encoder/decoder inputs (default=512).
      nhead: the number of heads in the multiheadattention models (default=8).
      num_encoder_layers: the number of sub-encoder-layers in the encoder (default=6).
      num_decoder_layers: the number of sub-decoder-layers in the decoder (default=6).
      dim_feedforward: the dimension of the feedforward network model (default=2048).
      dropout: the dropout value (default=0.1).
      custom_encoder: custom encoder (default=None).
      custom_decoder: custom decoder (default=None).
class_docstr_tok: ["A","transformer","model",".","User","is","able","to","modify","the","attributes","as","needed",".","The","architechture","is","based","on","the","paper","``","Attention","Is","All","You","Need","''",".","Ashish","Vaswani",",","Noam","Shazeer",",","Niki","Parmar",",","Jakob","Uszkoreit",",","Llion","Jones",",","Aidan","N","Gomez",",","Lukasz","Kaiser",",","and","Illia","Polosukhin",".","2017",".","Attention","is","all","you","need",".","In","Advances","in","Neural","Information","Processing","Systems",",","pages","6000-6010",".","Args",":","d_model",":","the","number","of","expected","features","in","the","encoder\/decoder","inputs","(","default=512",")",".","nhead",":","the","number","of","heads","in","the","multiheadattention","models","(","default=8",")",".","num_encoder_layers",":","the","number","of","sub-encoder-layers","in","the","encoder","(","default=6",")",".","num_decoder_layers",":","the","number","of","sub-decoder-layers","in","the","decoder","(","default=6",")",".","dim_feedforward",":","the","dimension","of","the","feedforward","network","model","(","default=2048",")",".","dropout",":","the","dropout","value","(","default=0.1",")",".","custom_encoder",":","custom","encoder","(","default=None",")",".","custom_decoder",":","custom","decoder","(","default=None",")","."]
docstr: Take in and process masked source/target sequences.
  Args:
      src: the sequence to the encoder (required).
      tgt: the sequence to the decoder (required).
  Shape:
      - src: :math:`(B, sN, C)`.
      - tgt: :math:`(B, tN, C)`.
  Examples:
      >>> output = transformer_model(src, tgt)
docstr_tok: ["Take","in","and","process","masked","source\/target","sequences",".","Args",":","src",":","the","sequence","to","the","encoder","(","required",")",".","tgt",":","the","sequence","to","the","decoder","(","required",")",".","Shape",":","-","src",":",":","math",":","`","(","B",",","sN",",","C",")","`",".","-","tgt",":",":","math",":","`","(","B",",","tN",",","C",")","`",".","Examples",":",">",">",">","output","=","transformer_model","(","src",",","tgt",")"]
code: def forward(self, src, targets=None):
      """Take in and process masked source/target sequences.
      Args:
          src: the sequence to the encoder (required).
          tgt: the sequence to the decoder (required).
      Shape:
          - src: :math:`(B, sN, C)`.
          - tgt: :math:`(B, tN, C)`.
      Examples:
          >>> output = transformer_model(src, tgt)
      """
  
      if self.training:
          max_len = targets[1].max()
          tgt = targets[0][:, : 2 + max_len]
          return self.forward_train(src, tgt)
      else:
          if self.beam_size > 0:
              return self.forward_beam(src)
          else:
              return self.forward_test(src)
  
imports: import math
  import paddle
  from paddle import nn
  import paddle.nn.functional
  from paddle.nn import LayerList
  from paddle.nn import Dropout, Linear, LayerNorm
  import numpy
  from ppocr.modeling.backbones.rec_svtrnet import Mlp, zeros_, ones_
  from paddle.nn.initializer import XavierNormal
label_desc: Use image node_id 4 for calling the Transformer obj's underlying member method code with example usage: obj.forward(src, targets) and returns: self, self, self