Converts tensor values into ClassificationResponse or RegressionResponse.

  Args:
    values: For classification, a 2D list of numbers. The first dimension is for
      each example being predicted. The second dimension are the probabilities
      for each class ID in the prediction. For regression, a 1D list of numbers,
      with a regression score for each example being predicted.
    serving_bundle: A `ServingBundle` object that contains the information about
      the serving request that the response was generated by.
    model_spec: Optional model spec to put into the response.

  Returns:
    A ClassificationResponse or RegressionResponse.

def convert_prediction_values(values, serving_bundle, model_spec=None):
  """Converts tensor values into ClassificationResponse or RegressionResponse.

  Args:
    values: For classification, a 2D list of numbers. The first dimension is for
      each example being predicted. The second dimension are the probabilities
      for each class ID in the prediction. For regression, a 1D list of numbers,
      with a regression score for each example being predicted.
    serving_bundle: A `ServingBundle` object that contains the information about
      the serving request that the response was generated by.
    model_spec: Optional model spec to put into the response.

  Returns:
    A ClassificationResponse or RegressionResponse.
  """
  if serving_bundle.model_type == 'classification':
    response = classification_pb2.ClassificationResponse()
    for example_index in range(len(values)):
      classification = response.result.classifications.add()
      for class_index in range(len(values[example_index])):
        class_score = classification.classes.add()
        class_score.score = values[example_index][class_index]
        class_score.label = str(class_index)
  else:
    response = regression_pb2.RegressionResponse()
    for example_index in range(len(values)):
      regression = response.result.regressions.add()
      regression.value = values[example_index]
  if model_spec:
    response.model_spec.CopyFrom(model_spec)
  return response