<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Download Test Data for XBRAIN
This notebook will walk through on how to download the test data necessary for the demo
Last Update
Step1:  Methods
Step2:  Parameters to pass to Google Drive
Step3:  Unzip the data to a directory
<ASSISTANT_TASK:>
Python Code:
# imports
import requests
import zipfile
import os
Explanation: Download Test Data for XBRAIN
This notebook will walk through on how to download the test data necessary for the demo
Last Update: 10/12/2017
End of explanation
# Methods to pull from google drive
def download_file_from_google_drive(id, destination):
    URL = "https://docs.google.com/uc?export=download"
    session = requests.Session()
    response = session.get(URL, params = { 'id' : id }, stream = True)
    token = get_confirm_token(response)
    if token:
        params = { 'id' : id, 'confirm' : token }
        response = session.get(URL, params = params, stream = True)
    save_response_content(response, destination)    
def get_confirm_token(response):
    for key, value in response.cookies.items():
        if key.startswith('download_warning'):
            return value
    return None
def save_response_content(response, destination):
    CHUNK_SIZE = 32768 #iterate by chunks of data to not loose information
    with open(destination, "wb") as f:
        for chunk in response.iter_content(CHUNK_SIZE):
            if chunk: # filter out keep-alive new chunks
                f.write(chunk)
Explanation: Methods
End of explanation
# download the zip
file_id = '0Bx1nyj-4aTk9RnNnS3JfRDZ6MVU' # the ID to the file on Google Drive
destination = 'public_data.zip'
# pass through the arguements
download_file_from_google_drive(file_id, destination)
Explanation: Parameters to pass to Google Drive
End of explanation
# unzip the data 
zip_ref = zipfile.ZipFile(destination, 'r')
zip_ref.extractall(os.getcwd())
zip_ref.close()
Explanation: Unzip the data to a directory
End of explanation
<END_TASK>