Grader found global variables inside graded fuctions. Please avoid using global variables in your functions

Hello ,

I am getting this error. However i have not used global variables anywhere in my functions.
Below is one function where i am getting this.
def tweet_to_tensor(tweet, vocab_dict, unk_token=‘UNK’, verbose=False):
‘’’
Input:
tweet - A string containing a tweet
vocab_dict - The words dictionary
unk_token - The special string for unknown tokens
verbose - Print info durign runtime
Output:
tensor_l - A python list with

'''     
### START CODE HERE (Replace instances of 'None' with your code) ###
# Process the tweet into a list of words
# where only important words are kept (stop words removed)
word_l = process_tweet(tweet)

if verbose:
    print("List of words from the processed tweet:")
    print(word_l)
    
# Initialize the list that will contain the unique integer IDs of each word
tensor_l = []

# Get the unique integer ID of the __UNK__ token
unk_ID = vocab_dict[unk_token]

if verbose:
    print(f"The unique integer ID for the unk_token is {unk_ID}")
    
# for each word in the list:
for word in word_l:
    
    # Get the unique integer ID.
    # If the word doesn't exist in the vocab dictionary,
    # use the unique ID for __UNK__ instead.
    word_ID = vocab_dict[word] if word in vocab_dict else unk_ID
### END CODE HERE ###
    
    # Append the unique integer ID to the tensor list.
    tensor_l.append(word_ID) 

return tensor_l

Please click my name and mail your notebook as an attachment.

Hi Balaji,
I have the same issue and resulting all sections of my answers having 0 points.

Go ahead, click my name and mail your notebook as an attachment.

@jishipp In function train_model, use function parameter named classifier instead of the global variable model.

@Giuseppe_Alessio_Dim You have done the same mistake. Use classifier inside train_model.