code: def model_deployment_data(
      model_name, deployment_version_id, model_version_id
  ):
      # here we want to get the value of user (i.e. ?start=0)
      start = request.args.get("start", 0)
      count = request.args.get("count", None)
      data_type = request.args.get("data_type", None)
      key_name = request.args.get("key_name", None)
      graph_type = request.args.get("graph_type", None)
  
      if not data_type and not key_name and not graph_type:
          return "error", 400
  
      # Get new data to add to the graphs
      filter = {
          "model_id": model_name,
          "deployment_version_id": deployment_version_id,
          "model_version_id": model_version_id,
          "start": int(start),
      }
      if count:
          filter["count"] = int(count)
      new_data = datmo_monitoring.search_metadata(filter)
  
      # update the number of new results
      num_new_results = len(new_data)
  
      # return error if data_type is not correct
      if data_type not in [
          "input",
          "prediction",
          "feedback",
          "system_metrics",
      ]:
          return "error", 400
  
      # populate the data into the correct construct based on graph type
      if graph_type == "timeseries":
          new_time_data = [
              datum["updated_at"]
              if datum["updated_at"]
              else datum["created_at"]
              for datum in new_data
          ]
          new_time_data_datetime = [
              datetime.fromtimestamp(float(t) / 1000).strftime(
                  "%Y-%m-%d %H:%M:%S"
              )
              for t in new_time_data
          ]
          new_feature_data = [
              datum[data_type][key_name] if datum[data_type] else None
              for datum in new_data
          ]
          graph_data_output = {
              "new_data": {
                  "x": [new_time_data_datetime],
                  "y": [new_feature_data],
              }
          }
  
      elif graph_type == "histogram":
          filter = {
              "model_id": model_name,
              "deployment_version_id": deployment_version_id,
              "model_version_id": model_version_id,
          }
          cumulative_data = datmo_monitoring.search_metadata(filter)
          cumulative_feature_data = [
              datum[data_type][key_name]
              for datum in cumulative_data
              if datum[data_type]
              and key_name in datum[data_type].keys()
          ]
          import numpy as np
  
          counts, binedges = np.histogram(cumulative_feature_data)
          binsize = binedges[1] - binedges[0]
          bin_names = [
              str(round(binedge, 2))
              + " : "
              + str(round(binedge + binsize, 2))
              for binedge in binedges
          ]
          graph_data_output = {
              "cumulative_data": {"x": [bin_names], "y": [counts]}
          }
      elif graph_type == "gauge":
          new_feature_data = [
              datum[data_type][key_name] if datum[data_type] else None
              for datum in new_data
          ]
          if len(new_feature_data) > 0:
              average = sum(new_feature_data) / float(
                  len(new_feature_data)
              )
          else:
              average = None
          graph_data_output = {"average": average}
      else:
          return "error", 400
  
      # Convert the figures to JSON
      # PlotlyJSONEncoder appropriately converts pandas, datetime, etc
      # objects to their JSON equivalents
      graph_data_outputJSON = json.dumps(
          graph_data_output, cls=plotly.utils.PlotlyJSONEncoder
      )
  
      return jsonify(
          graph_data_output_json_str=graph_data_outputJSON,
          num_new_results=num_new_results,
      )
  
imports: import os
  import shutil
  import uuid
  import json
  from flask import Flask, url_for
  from flask import render_template, request, jsonify
  import plotly
  from datetime import datetime
  from datmo.config import Config
  from datmo.core.entity.run import Run
  from datmo.core.controller.base import BaseController
  from datmo.core.util.misc_functions import prettify_datetime, printable_object
label_desc: Use image node_id 5 for calling a global function with example usage: model_deployment_data(model_name, deployment_version_id, model_version_id) and returns: jsonify, str,  int, str,  int, str,  int