input: def analyze_sentiment(text: str) -> dict:
      """ Analyze the sentiment of a given text by tokenizing it, removing stopwords, 
      stemming the words, and then calculating the polarity score.
      >>> analyze_sentiment("I love this product! It's amazing.")
      {'neg': 0.0, 'neu': 0.254, 'pos': 0.746, 'compound': 0.8316}
      >>> analyze_sentiment("I hate this product. It's terrible.")
      {'neg': 0.609, 'neu': 0.391, 'pos': 0.0, 'compound': -0.7271}
      """
output:     from nltk.sentiment import SentimentIntensityAnalyzer
      from nltk.tokenize import word_tokenize
      from nltk.corpus import stopwords
      from nltk.stem import PorterStemmer
      import string
  
      # Tokenize the text
      tokens = word_tokenize(text.lower())
  
      # Remove stopwords and punctuation
      stop_words = set(stopwords.words('english'))
      filtered_tokens = [word for word in tokens if word.isalpha() and word not in stop_words]
  
      # Stem the words
      stemmer = PorterStemmer()
      stemmed_tokens = [stemmer.stem(word) for word in filtered_tokens]
  
      # Join the stemmed tokens back into a single string
      processed_text = ' '.join(stemmed_tokens)
  
      # Calculate sentiment scores
      sia = SentimentIntensityAnalyzer()
      sentiment_scores = sia.polarity_scores(processed_text)
  
      return sentiment_scores