code: def init_context_word_embs_sentence_model(
      model_path,
      model_type,
      device,
      force_reload=False,
      min_length=100,
      max_length=300,
      batch_size=32,
      temperature=1.0,
      top_k=50,
      top_p=0.9,
      silence=True,
      use_custom_api=True,
  ):
      global CONTEXT_WORD_EMBS_SENTENCE_MODELS
  
      model_name = "_".join([os.path.basename(model_path), str(device)])
      if (
          model_name in CONTEXT_WORD_EMBS_SENTENCE_MODELS
          and not force_reload
      ):
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[
              model_name
          ].min_length = min_length
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[
              model_name
          ].max_length = max_length
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[
              model_name
          ].temperature = temperature
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[model_name].top_k = top_k
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[model_name].top_p = top_p
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[
              model_name
          ].batch_size = batch_size
          CONTEXT_WORD_EMBS_SENTENCE_MODELS[
              model_name
          ].silence = silence
          return CONTEXT_WORD_EMBS_SENTENCE_MODELS[model_name]
  
      if use_custom_api:
          if model_type == "xlnet":
              model = nml.XlNet(
                  model_path,
                  device=device,
                  temperature=temperature,
                  top_k=top_k,
                  optimize=None,
                  silence=True,
              )
          elif model_type == "gpt2":
              model = nml.Gpt2(
                  model_path,
                  device=device,
                  temperature=temperature,
                  top_k=top_k,
                  optimize=None,
                  silence=True,
              )
          else:
              raise ValueError(
                  "Model name value is unexpected. Only support XLNet and GPT2 model."
              )
      else:
          model = nml.TextGenTransformers(
              model_path,
              device=device,
              min_length=min_length,
              max_length=max_length,
              temperature=temperature,
              top_k=top_k,
              top_p=top_p,
              batch_size=batch_size,
          )
  
      CONTEXT_WORD_EMBS_SENTENCE_MODELS[model_name] = model
      return model
  
file_path: nlpaug/nlpaug/augmenter/sentence/context_word_embs_sentence.py
imports: import os
  from typing import Iterable
  from nlpaug.augmenter.sentence import SentenceAugmenter
  import nlpaug.model.lang_models
  from nlpaug.util import Action, Doc
  import nlpaug.util.text.tokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: init_context_word_embs_sentence_model(model_path, model_type, device, force_reload, min_length, max_length, batch_size, temperature, top_k, top_p, silence, use_custom_api) and returns: model, CONTEXT_WORD_EMBS_SENTENCE_MODELS