docstr: Build model with a generator, This function will do:
  
  1. setup processor's vocab if the vocab is empty.
  2. calculate the sequence length if `sequence_length` is None.
  3. build up model architect.
  4. compile the ``tf_model`` with default loss, optimizer and metrics.
  
  Args:
      train_gen: train data generator
docstr_tok: ["Build","model","with","a","generator",",","This","function","will","do",":","1.","setup","processor","'s","vocab","if","the","vocab","is","empty",".","2.","calculate","the","sequence","length","if","`","sequence_length","`","is","None",".","3.","build","up","model","architect",".","4.","compile","the","``","tf_model","``","with","default","loss",",","optimizer","and","metrics",".","Args",":","train_gen",":","train","data","generator"]
code: def build_model_generator(self, train_gen: CorpusGenerator) -> None:
      """
      Build model with a generator, This function will do:
  
      1. setup processor's vocab if the vocab is empty.
      2. calculate the sequence length if `sequence_length` is None.
      3. build up model architect.
      4. compile the ``tf_model`` with default loss, optimizer and metrics.
  
      Args:
          train_gen: train data generator
  
      """
      if self.encoder is None:
          self.encoder_processor.build_vocab_generator([train_gen])
          self.decoder_processor.build_vocab_generator([train_gen])
          self.encoder_embedding.setup_text_processor(
              self.encoder_processor
          )
          self.decoder_embedding.setup_text_processor(
              self.decoder_processor
          )
  
          if self.encoder_seq_length is None:
              self.encoder_seq_length = (
                  self.encoder_embedding.get_seq_length_from_corpus(
                      [train_gen], cover_rate=1.0
                  )
              )
              logger.info(
                  f"calculated encoder sequence length: {self.encoder_seq_length}"
              )
  
          if self.decoder_seq_length is None:
              self.decoder_seq_length = (
                  self.decoder_embedding.get_seq_length_from_corpus(
                      [train_gen], use_label=True, cover_rate=1.0
                  )
              )
              logger.info(
                  f"calculated decoder sequence length: {self.decoder_seq_length}"
              )
  
          self._build_encoder_decoder()
  
imports: import json
  import os
  import pathlib
  from typing import Any, Tuple, List, Dict
  import numpy
  import tensorflow
  import tqdm
  import kashgari
  from kashgari.embeddings import BareEmbedding
  from kashgari.embeddings.abc_embedding import ABCEmbedding
  from kashgari.generators import CorpusGenerator, Seq2SeqDataSet
  from kashgari.logger import logger
  from kashgari.processors import SequenceProcessor
  from kashgari.tasks.seq2seq.decoder import AttGRUDecoder
  from kashgari.tasks.seq2seq.encoder import GRUEncoder
  from kashgari.types import TextSamplesVar
label_desc: Use image node_id 6 for calling the Seq2Seq obj's underlying member method code with example usage: obj.build_model_generator(train_gen) without return types