class_docstr: This lobe enables the integration of HuggingFace pretrained GPT model.
   Source paper whisper:
      https://life-extension.github.io/2020/05/27/GPT%E6%8A%80%E6%9C%AF%E5%88%9D%E6%8E%A2/language-models.pdf
  Transformer from HuggingFace needs to be installed:
      https://huggingface.co/transformers/installation.html
  
  The model can be finetuned. It will download automatically the model from
  HuggingFace or use a local path.
  
  Arguments
  ---------
  source : str
      HuggingFace hub name: e.g "gpt2"
  save_path : str
      Path (dir) of the downloaded model.
  freeze : bool (default: False)
      If True, the model is frozen. If False, the model will be trained
      alongside with the rest of the pipeline.
  Example
  -------
  >>> model_hub = "gpt2"
  >>> save_path = "savedir"
  >>> model = GPT(model_hub, save_path)
  >>> tokens = torch.tensor([[1, 1]])
  >>> tokens_type = torch.tensor([[1, 1]])
  >>> attention_mask = torch.tensor([[1, 1]])
  >>> outputs = model(tokens, tokens_type, attention_mask)
docstr: Takes an input a history of conversation and returns its corresponding reply.
  
  Arguments
  --------
  input_ids : torch.Tensor ()
      A batch of input-id   which are dialogue context tokens
  decoder_type : Str
      It shows strategy for autoregressive decoding either beam seach or greedy.
  attention_mask : torch.Tensor ()
      A batch of attention_mask.
docstr_tok: ["Takes","an","input","a","history","of","conversation","and","returns","its","corresponding","reply",".","Arguments","--","--","--","--","input_ids",":","torch.Tensor","(",")","A","batch","of","input-id","which","are","dialogue","context","tokens","decoder_type",":","Str","It","shows","strategy","for","autoregressive","decoding","either","beam","seach","or","greedy",".","attention_mask",":","torch.Tensor","(",")","A","batch","of","attention_mask","."]
code: def generate(
      self,
      input_ids: Tensor,
      token_type_ids,
      attention_mask: Tensor,
      decoder_type="greedy",
  ):
      """Takes an input a history of conversation and returns its corresponding reply.
  
      Arguments
      --------
      input_ids : torch.Tensor ()
          A batch of input-id   which are dialogue context tokens
      decoder_type : Str
          It shows strategy for autoregressive decoding either beam seach or greedy.
      attention_mask : torch.Tensor ()
          A batch of attention_mask.
      """
  
      with torch.no_grad():
          if decoder_type == "beam":
              # beam decoding based on the input_ids which are dialogue context tokens (here only history)
              hyp = self.model.generate(
                  input_ids=input_ids,
                  token_type_ids=token_type_ids,
                  attention_mask=attention_mask,
                  do_sample=True,
                  max_new_tokens=self.max_new_tokens,
                  min_length=self.min_length,
                  top_k=self.top_k,
                  top_p=self.top_p,
                  num_beams=self.num_beams,
                  num_return_sequences=1,
                  eos_token_id=self.eos_token_id,
                  early_stopping=self.early_stopping,
              )
          else:
              # greedy decoding based on the input_ids which are dialogue context tokens (here only history)
              hyp = self.model.generate(
                  input_ids,
                  token_type_ids=token_type_ids,
                  max_new_tokens=self.max_new_tokens,
                  eos_token_id=self.eos_token_id,
                  attention_mask=attention_mask,
              )
      return hyp
  
file_path: speechbrain/speechbrain/lobes/models/huggingface_transformers/gpt.py
imports: import logging
  from torch import Tensor
  import torch
  from speechbrain.lobes.models.huggingface_transformers.huggingface import HFTransformersInterface
label_desc: Use image node_id 3 for calling the GPT obj's underlying member method code with example usage: obj.generate(input_ids, token_type_ids, attention_mask, decoder_type) and returns: hyp