class_docstr: A self attention layer.
  Input is a list which consists of 4 ndarrays.
  1. Token id ndarray: shape [batch, seqLen] with the word token indices in the vocabulary
  2. Token type id ndarray: shape [batch, seqLen] with the token types in [0, 1].
     0 means `sentence A` and 1 means a `sentence B` (see BERT paper for more details).
  3. Position id ndarray: shape [batch, seqLen] with positions in the sentence.
  4. Attention_mask ndarray: shape [batch, seqLen] with indices in [0, 1].
     It's a mask to be used if the input sequence length is smaller than seqLen in
     the current batch.
  Output is a list which contains:
  1. The states of BERT layer.
  2. The pooled output which processes the hidden state of the last layer with regard to the first
  token of the sequence. This would be useful for segment-level tasks.
  
  # Arguments
  n_block: block number
  n_head: head number
  intermediate_size: The size of the "intermediate" (i.e., feed-forward)
  hidden_drop: The dropout probability for all fully connected layers
  attn_drop: drop probability of attention
  initializer_ranger: weight initialization range
  output_all_block: whether output all blocks' output
  embedding_layer: embedding layer
  input_shape: input shape
class_docstr_tok: ["A","self","attention","layer",".","Input","is","a","list","which","consists","of","4","ndarrays",".","1",".","Token","id","ndarray",":","shape","[","batch",",","seqLen","]","with","the","word","token","indices","in","the","vocabulary","2",".","Token","type","id","ndarray",":","shape","[","batch",",","seqLen","]","with","the","token","types","in","[","0",",","1","]",".","0","means","`","sentence","A","`","and","1","means","a","`","sentence","B","`","(","see","BERT","paper","for","more","details",")",".","3",".","Position","id","ndarray",":","shape","[","batch",",","seqLen","]","with","positions","in","the","sentence",".","4",".","Attention_mask","ndarray",":","shape","[","batch",",","seqLen","]","with","indices","in","[","0",",","1","]",".","It","'s","a","mask","to","be","used","if","the","input","sequence","length","is","smaller","than","seqLen","in","the","current","batch",".","Output","is","a","list","which","contains",":","1",".","The","states","of","BERT","layer",".","2",".","The","pooled","output","which","processes","the","hidden","state","of","the","last","layer","with","regard","to","the","first","token","of","the","sequence",".","This","would","be","useful","for","segment-level","tasks",".","#","Arguments","n_block",":","block","number","n_head",":","head","number","intermediate_size",":","The","size","of","the","``","intermediate","''","(","i.e.",",","feed-forward",")","hidden_drop",":","The","dropout","probability","for","all","fully","connected","layers","attn_drop",":","drop","probability","of","attention","initializer_ranger",":","weight","initialization","range","output_all_block",":","whether","output","all","blocks","'","output","embedding_layer",":","embedding","layer","input_shape",":","input","shape"]
docstr: Load an existing BERT model (with weights).
  
  # Arguments
  path: The path for the pre-defined model.
        Local file system, HDFS and Amazon S3 are supported.
        HDFS path should be like 'hdfs://[host]:[port]/xxx'.
        Amazon S3 path should be like 's3a://bucket/xxx'.
  weight_path: The path for pre-trained weights if any. Default is None.
docstr_tok: ["Load","an","existing","BERT","model","(","with","weights",")",".","#","Arguments","path",":","The","path","for","the","pre-defined","model",".","Local","file","system",",","HDFS","and","Amazon","S3","are","supported",".","HDFS","path","should","be","like","'hdfs",":","\/\/","[","host","]",":","[","port","]","\/xxx","'",".","Amazon","S3","path","should","be","like","'s3a",":","\/\/bucket\/xxx","'",".","weight_path",":","The","path","for","pre-trained","weights","if","any",".","Default","is","None","."]
code: def init_from_existing_model(
      path,
      weight_path=None,
      input_seq_len=-1.0,
      hidden_drop=-1.0,
      attn_drop=-1.0,
      output_all_block=True,
      bigdl_type="float",
  ):
      """
      Load an existing BERT model (with weights).
  
      # Arguments
      path: The path for the pre-defined model.
            Local file system, HDFS and Amazon S3 are supported.
            HDFS path should be like 'hdfs://[host]:[port]/xxx'.
            Amazon S3 path should be like 's3a://bucket/xxx'.
      weight_path: The path for pre-trained weights if any. Default is None.
      """
      jlayer = callZooFunc(
          bigdl_type,
          "loadBERT",
          path,
          weight_path,
          input_seq_len,
          hidden_drop,
          attn_drop,
          output_all_block,
      )
  
      model = Layer(jvalue=jlayer, bigdl_type=bigdl_type)
      model.__class__ = BERT
      return model
  
imports: import numpy
  import math
  from bigdl.dllib.nn.layer import Sum
  from bigdl.dllib.nn.layer import Layer
  from bigdl.dllib.utils.file_utils import callZooFunc
  from bigdl.dllib.keras.engine import ZooKerasLayer
  from bigdl.dllib.keras.layers import *
  from bigdl.dllib.keras.models import Sequential
  from bigdl.dllib.keras.models import Model
  import bigdl.dllib.keras.autograd
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 6 for calling the BERT obj's underlying member method code with example usage: obj.init_from_existing_model(path, weight_path, input_seq_len, hidden_drop, attn_drop, output_all_block, bigdl_type) and returns: model