<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cloud_predict(model_name, model_version, data):
 """Use Online prediction. Runs online prediction in the cloud and prints the results to the screen. For running prediction on a large dataset or saving the results, run local_batch_prediction or batch_prediction. Args: model_name: deployed model name model_version: depoyed model version data: List of csv strings or a Pandas DataFrame that match the model schema. Before using this, the model must be created. This can be done by running two gcloud commands: 1) gcloud beta ml models create NAME 2) gcloud beta ml versions create VERSION --model NAME \ --origin gs://BUCKET/training_dir/model or these datalab commands: 1) import google.datalab as datalab model = datalab.ml.ModelVersions(MODEL_NAME) model.deploy(version_name=VERSION, path='gs://BUCKET/training_dir/model') Note that the model must be on GCS. """

  import google.datalab.ml as ml

  if isinstance(data, pd.DataFrame):
    # write the df to csv.
    string_buffer = io.StringIO()
    data.to_csv(string_buffer, header=None, index=False)
    input_data = string_buffer.getvalue().split('\n')

    # remove empty strings
    input_data = [line for line in input_data if line]
  else:
    input_data = data

  predictions = ml.ModelVersions(model_name).predict(model_version, input_data)

  # Convert predictions into a dataframe
  df = pd.DataFrame(columns=sorted(predictions[0].keys()))
  for i in range(len(predictions)):
    for k, v in predictions[i].iteritems():
      df.loc[i, k] = v
  return df