code: def finalize_metric_results(
      self, metric_types, metric_dtypes, metric_results
  ):
      for m_idx in range(len(metric_types)):
          metric_type, metric_dtype, metric_result = (
              metric_types[m_idx],
              metric_dtypes[m_idx],
              metric_results[m_idx],
          )
          if metric_type == "single_value_per_sample":
              metric_fname = metric_result["sample_to_metric_fname"]
              close_mmap_dataset_builder(
                  metric_result["sample_to_metric_builder"],
                  metric_fname,
              )
              for m_value in metric_result["metric_to_sample_dict"]:
                  if (
                      len(
                          metric_result["metric_to_sample_dict"][
                              m_value
                          ]
                      )
                      > 0
                  ):
                      metric_fname = metric_result[
                          "metric_to_sample_fname"
                      ]
                      with open(
                          f"{metric_fname}_{m_value}.csv", "a"
                      ) as f:
                          writer = csv.writer(f)
                          writer.writerows(
                              [
                                  metric_result[
                                      "metric_to_sample_dict"
                                  ][m_value]
                              ]
                          )
                      metric_result["metric_to_sample_dict"][
                          m_value
                      ] = []
          elif metric_type == "accumulate_value_over_samples":
              if metric_result["metric_value"] is not None:
                  metric_value_builder = create_mmap_dataset_builder(
                      metric_result["metric_value_fname"], metric_dtype
                  )
                  metric_value_builder.add_item(
                      metric_result["metric_value"].reshape(-1)
                  )
                  close_mmap_dataset_builder(
                      metric_value_builder,
                      metric_result["metric_value_fname"],
                  )
  
imports: import os
  from collections import defaultdict
  import csv
  import time
  from multiprocessing import Process, Manager
  import numpy
  import torch
  from torch.utils.data import BatchSampler, SequentialSampler, DataLoader, Subset
  from deepspeed.utils import logger
  from .indexed_dataset import MMapIndexedDataset
  from .utils import split_dataset, split_index, create_mmap_dataset_builder, close_mmap_dataset_builder, find_fit_int_dtype
label_desc: Use image node_id 4 for calling the DataAnalyzer obj's underlying member method code with example usage: obj.finalize_metric_results(metric_types, metric_dtypes, metric_results) without return types