code: def collect_requested_metric_traces(
      run: Run, requested_traces: List[TraceBase], steps_num: int = 200
  ) -> List[dict]:
      processed_traces_list = []
      for requested_trace in requested_traces:
          metric_name = requested_trace.name
          context = Context(requested_trace.context)
          trace = run.get_metric(name=metric_name, context=context)
          if not trace:
              continue
  
          iters, (values,) = (
              trace.data.view("val").sample(steps_num).items_list()
          )
          values = list(
              map(
                  lambda x: x
                  if float("-inf") < x < float("inf") and x == x
                  else None,
                  values,
              )
          )
  
          processed_traces_list.append(
              {
                  "name": trace.name,
                  "context": trace.context.to_dict(),
                  "values": values,
                  "iters": iters,
              }
          )
  
      return processed_traces_list
  
imports: import asyncio
  import numpy
  import random
  import struct
  import time
  from collections import namedtuple
  from itertools import chain
  from typing import Iterator, Tuple, Optional, List
  from typing import TYPE_CHECKING
  from fastapi import HTTPException
  from aim.storage.context import Context
  from aim.sdk import Run
  from aim.sdk.sequences.metric import Metric
  from aim.sdk.sequence_collection import SequenceCollection
  from aim.storage.query import syntax_error_check
  from aim.web.configs import AIM_PROGRESS_REPORT_INTERVAL
  from aim.web.api.projects.project import Project
  from aim.web.api.runs.pydantic_models import AlignedRunIn, TraceBase
  from aim.storage.treeutils import encode_tree
label_desc: Use image node_id 9 for calling a global function with example usage: collect_requested_metric_traces(run, requested_traces, steps_num) and returns: processed_traces_list