code: def get_metrics_tracking_util(
      track_data: List[Dict[str, Any]],
      preference_data: List[int],
      is_metric_summary: bool,
  ):
      filtered_track_data = []
      if len(preference_data) == len(track_data) and is_metric_summary:
          for i in range(len(track_data)):
              filtered_track_data.append(track_data[i])
              if preference_data[i] == -1:
                  filtered_track_data[-1][
                      "value"
                  ] = filtered_track_data[-1]["value"][-1:]
                  filtered_track_data[-1]["step"] = filtered_track_data[
                      -1
                  ]["step"][-1:]
                  filtered_track_data[-1][
                      "smoothed"
                  ] = filtered_track_data[-1]["smoothed"][-1:]
                  filtered_track_data[-1]["is_summary"] = True
              else:
                  filtered_track_data[-1]["is_summary"] = False
      else:  # initially (when no pref data) send all data
          filtered_track_data = track_data
          for i in range(len(track_data)):
              filtered_track_data[i]["is_summary"] = False
  
      return filtered_track_data
  
imports: from typing import Dict, Any, List, Optional
  from fastapi import Request
  from fastapi.responses import JSONResponse
  from labml_db import Model, Index, load_keys
  from labml_db.serializer.pickle import PickleSerializer
  from labml_db.serializer.yaml import YamlSerializer
  from labml_app.logger import logger
  from labml_app import utils
  from labml_app.enums import INDICATORS
  from .distributed_metrics import get_merged_dist_metrics_tracking, set_merged_metrics_preferences, get_merged_metrics_preferences
  from ..analysis import Analysis
  from ..series import SeriesModel, Series
  from ..series_collection import SeriesCollection
  from ..preferences import Preferences
  from labml_app.settings import INDICATOR_LIMIT
  from ...db import run
label_desc: Use image node_id 3 for calling a global function with example usage: get_metrics_tracking_util(track_data, preference_data, is_metric_summary) and returns: filtered_track_data