class_docstr: This lobe provides an interface for integrating any HuggingFace transformer model within SpeechBrain.
  
  We use AutoClasses for loading any model from the hub and its necessary components.
  For example, we build Wav2Vec2 class which inherits HFTransformersInterface for working with HuggingFace's wav2vec models.
  While Wav2Vec2 can enjoy some already built features like modeling loading, pretrained weights loading, all weights freezing,
  feature_extractor loading, etc.
  Users are expected to override the essential forward() function to fit their specific needs.
  Depending on the HuggingFace transformer model in question, one can also modify the state_dict by overwriting the _modify_state_dict() method,
  or adapting their config by modifying override_config() method, etc.
  See:
  https://huggingface.co/docs/transformers/model_doc/auto
  https://huggingface.co/docs/transformers/autoclass_tutorial
  
  Arguments
  ---------
  source : str
      HuggingFace hub name: e.g "facebook/wav2vec2-large-lv60"
  save_path : str
      save directory of the downloaded model.
  for_pretraining: bool (default: False)
      If True, build the model for pretraining
  with_lm_head : bool (default: False)
      If True, build the model with lm_head
  with_casual_lm : bool (default: False)
      If True, build casual lm  model
  seq2seqlm : bool (default: False)
      If True, build a sequence-to-sequence model with lm_head
  quantization_config : dict (default: None)
      Quantization config, extremely useful for deadling with LLM
  freeze : bool (default: True)
      If True, the model is frozen. If False, the model will be trained
      alongside with the rest of the pipeline.
  cache_dir : str or Path (default: None)
      Location of HuggingFace cache for storing pre-trained models, to which symlinks are created.
  
  Example
  -------
  >>> model_hub = "facebook/wav2vec2-base-960h"
  >>> save_path = "tmp"
  >>> model = HFTransformersInterface(model_hub, save_path=save_path)
class_docstr_tok: ["This","lobe","provides","an","interface","for","integrating","any","HuggingFace","transformer","model","within","SpeechBrain",".","We","use","AutoClasses","for","loading","any","model","from","the","hub","and","its","necessary","components",".","For","example",",","we","build","Wav2Vec2","class","which","inherits","HFTransformersInterface","for","working","with","HuggingFace","'s","wav2vec","models",".","While","Wav2Vec2","can","enjoy","some","already","built","features","like","modeling","loading",",","pretrained","weights","loading",",","all","weights","freezing",",","feature_extractor","loading",",","etc",".","Users","are","expected","to","override","the","essential","forward","(",")","function","to","fit","their","specific","needs",".","Depending","on","the","HuggingFace","transformer","model","in","question",",","one","can","also","modify","the","state_dict","by","overwriting","the","_modify_state_dict","(",")","method",",","or","adapting","their","config","by","modifying","override_config","(",")","method",",","etc",".","See",":","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/auto","https",":","\/\/huggingface.co\/docs\/transformers\/autoclass_tutorial","Arguments","--","--","--","--","-","source",":","str","HuggingFace","hub","name",":","e.g","``","facebook\/wav2vec2-large-lv60","''","save_path",":","str","save","directory","of","the","downloaded","model",".","for_pretraining",":","bool","(","default",":","False",")","If","True",",","build","the","model","for","pretraining","with_lm_head",":","bool","(","default",":","False",")","If","True",",","build","the","model","with","lm_head","with_casual_lm",":","bool","(","default",":","False",")","If","True",",","build","casual","lm","model","seq2seqlm",":","bool","(","default",":","False",")","If","True",",","build","a","sequence-to-sequence","model","with","lm_head","quantization_config",":","dict","(","default",":","None",")","Quantization","config",",","extremely","useful","for","deadling","with","LLM","freeze",":","bool","(","default",":","True",")","If","True",",","the","model","is","frozen",".","If","False",",","the","model","will","be","trained","alongside","with","the","rest","of","the","pipeline",".","cache_dir",":","str","or","Path","(","default",":","None",")","Location","of","HuggingFace","cache","for","storing","pre-trained","models",",","to","which","symlinks","are","created",".","Example","--","--","--","-",">",">",">","model_hub","=","``","facebook\/wav2vec2-base-960h","''",">",">",">","save_path","=","``","tmp","''",">",">",">","model","=","HFTransformersInterface","(","model_hub",",","save_path=save_path",")"]
docstr: Users should modify this function according to their own tasks.
docstr_tok: ["Users","should","modify","this","function","according","to","their","own","tasks","."]
code: def forward_encoder(self, **kwargs):
      """Users should modify this function according to their own tasks."""
      raise NotImplementedError
  
imports: import os
  import torch
  import logging
  import pathlib
  from torch import nn
  from huggingface_hub import model_info
  from speechbrain.utils.fetching import fetch
  from speechbrain.dataio.dataio import length_to_mask
  from transformers import AutoConfig, AutoTokenizer, AutoFeatureExtractor, AutoModelForPreTraining, AutoModel, AutoModelWithLMHead, AutoModelForSeq2SeqLM, AutoModelForCausalLM
label_desc: Use image node_id 7 for calling the HFTransformersInterface obj's underlying member method code with example usage: obj.forward_encoder() without return types