<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def predict(data, training_dir=None, model_name=None, model_version=None, cloud=False):
 """Runs prediction locally or on the cloud. Args: data: List of csv strings or a Pandas DataFrame that match the model schema. training_dir: local path to the trained output folder. model_name: deployed model name model_version: depoyed model version cloud: bool. If False, does local prediction and data and training_dir must be set. If True, does cloud prediction and data, model_name, and model_version must be set. For cloud prediction, 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. Returns: Pandas DataFrame. """

  if cloud:
    if not model_version or not model_name:
      raise ValueError('model_version or model_name is not set')
    if training_dir:
      raise ValueError('training_dir not needed when cloud is True')
    with warnings.catch_warnings():
      warnings.simplefilter("ignore")
      return cloud_predict(model_name, model_version, data)
  else:
    if not training_dir:
      raise ValueError('training_dir is not set')
    if model_version or model_name:
      raise ValueError('model_name and model_version not needed when cloud is '
                       'False.')
    with warnings.catch_warnings():
      warnings.simplefilter("ignore")
      return local_predict(training_dir, data)