AttributeError: 'Vocab' object has no attribute 'vocab'

username: seanbenhur
cooked: <p>I have created a text classification model and also created a seperate vocabulary file  when I try to create a streamlit model I get this error<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/2/328e290f168217b95710d758c6d49116de8a91cd.png" data-download-href="https://discuss.pytorch.org/uploads/default/328e290f168217b95710d758c6d49116de8a91cd" title="torch"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/2/328e290f168217b95710d758c6d49116de8a91cd_2_690x334.png" alt="torch" data-base62-sha1="7derWFl35qJPLKlwJAgiPpUBSkB" width="690" height="334" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/2/328e290f168217b95710d758c6d49116de8a91cd_2_690x334.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/2/328e290f168217b95710d758c6d49116de8a91cd_2_1035x501.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/2/328e290f168217b95710d758c6d49116de8a91cd.png 2x" data-dominant-color="FAEEEE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">torch</span><span class="informations">1334×647 29.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>code for app file</p>
<pre><code class="lang-auto">
import re
import pickle
import spacy
import torchtext
import torch
import streamlit as st
from config import *
from models.cnn import CNN
from torchtext import vocab


try:
    vocab._default_unk_index
except AttributeError:
    def _default_unk_index():
        return 0
    vocab._default_unk_index = _default_unk_index
pretrained_model_path = "/content/drive/MyDrive/Models/INTENT/cnn-model.pt"
pretrained_vocab_path = "/content/drive/MyDrive/Models/INTENT/cnndict.pkl"

# load spacy's nlp model for tokenization
nlp = spacy.load("en")
# load the model
model = CNN(INPUT_DIM, EMBEDDING_DIM, N_FILTERS, FILTER_SIZES, OUTPUT_DIM, DROPOUT)

@st.cache()
def load_model(model_path):
  """
  # load the pretrained model path
  """
  return model.load_state_dict(torch.load(pretrained_model_path)) 

# load the pretrained vocab file
with open(pretrained_vocab_path, "rb") as f:
    TEXT = pickle.load(f)


def predict_class(intent, model=model):
    model.eval()
    tokenized = [tok.text for tok in nlp.tokenizer(intent)]
    indexed = [TEXT.vocab.Vocab.stoi[t] for t in tokenized]
    tensor = torch.LongTensor(indexed).to(device)
    tensor = tensor.unsqueeze(1)
    preds = model(tensor)
    max_pred = preds.argmax(dim=1)
    return max_pred.item()

#streamlit --code
st.title("Intent recogntion using Machine learning!")
intent = st.text_area("Enter a intent","Type Here..")
if st.button("Anaalyze"):
  with st.spinner("Analyzing the intent..."):
    prediction = predict_class(intent)
    if prediction==0:
      st.success("Add to playlist")
    elif prediction==1:
      st.success("Book a Restaurent")
    elif prediction==2:
      st.success("Get weather  info")
    elif prediction==3:
      st.success("Play music")
    elif prediction==4:
      st.success("Rate a book")
    elif prediction==5:
      st.success("Search for creative work")
    elif prediction==6:
      st.success("Search for screening event")```

Now how to avoid this error please help!</code></pre>

username: Abhilash_Srivastava
cooked: <aside class="quote no-group" data-username="seanbenhur" data-post="1" data-topic="107650">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/seanbenhur/48/30526_2.png" class="avatar"> seanbenhur:</div>
<blockquote>
<p><code>TEXT.vocab.Vocab.stoi[t]</code></p>
</blockquote>
</aside>
<p>Try replacing this with <code>TEXT.vocab.stoi[t]</code>.</p>