class_docstr: Metrics manager and batch writer 
class_docstr_tok: ["Metrics","manager","and","batch","writer"]
code: def report_offline_session(cls, task, folder, iteration_offset=0):
      from ... import StorageManager
  
      filename = Path(folder) / cls.__offline_filename
      if not filename.is_file():
          return False
      # noinspection PyProtectedMember
      remote_url = task._get_default_report_storage_uri()
      if remote_url and remote_url.endswith("/"):
          remote_url = remote_url[:-1]
      uploaded_files = set()
      task_id = task.id
      with open(filename.as_posix(), "rt") as f:
          i = 0
          while True:
              try:
                  line = f.readline()
                  if not line:
                      break
                  list_requests = json.loads(line)
                  for r in list_requests:
                      # noinspection PyBroadException
                      try:
                          r["iter"] += iteration_offset
                      except Exception:
                          pass
                      org_task_id = r["task"]
                      r["task"] = task_id
                      if r.get("key") and r.get("url"):
                          debug_sample = (
                              Path(folder) / "data"
                          ).joinpath(*(r["key"].split("/")))
                          r["key"] = r["key"].replace(
                              ".{}{}".format(org_task_id, os.sep),
                              ".{}{}".format(task_id, os.sep),
                              1,
                          )
                          r["url"] = "{}/{}".format(
                              remote_url, r["key"]
                          )
                          if (
                              debug_sample not in uploaded_files
                              and debug_sample.is_file()
                          ):
                              uploaded_files.add(debug_sample)
                              StorageManager.upload_file(
                                  local_file=debug_sample.as_posix(),
                                  remote_url=r["url"],
                              )
                      elif r.get("plot_str"):
                          # hack plotly embedded images links
                          # noinspection PyBroadException
                          try:
                              task_id_sep = ".{}{}".format(
                                  org_task_id, os.sep
                              )
                              plot = json.loads(r["plot_str"])
                              if plot.get("layout", {}).get("images"):
                                  for image in plot["layout"]["images"]:
                                      if (
                                          task_id_sep
                                          not in image["source"]
                                      ):
                                          continue
                                      pre, post = image["source"].split(
                                          task_id_sep, 1
                                      )
                                      pre = os.sep.join(
                                          pre.split(os.sep)[-2:]
                                      )
                                      debug_sample = (
                                          Path(folder) / "data"
                                      ).joinpath(
                                          pre
                                          + ".{}".format(org_task_id),
                                          post,
                                      )
                                      image["source"] = "/".join(
                                          [
                                              remote_url,
                                              pre
                                              + ".{}".format(task_id),
                                              post,
                                          ]
                                      )
                                      if (
                                          debug_sample
                                          not in uploaded_files
                                          and debug_sample.is_file()
                                      ):
                                          uploaded_files.add(
                                              debug_sample
                                          )
                                          StorageManager.upload_file(
                                              local_file=debug_sample.as_posix(),
                                              remote_url=image[
                                                  "source"
                                              ],
                                          )
                              r["plot_str"] = json.dumps(plot)
                          except Exception:
                              pass
                  i += 1
              except StopIteration:
                  break
              except Exception as ex:
                  warning(
                      "Failed reporting metric, line {} [{}]".format(
                          i, ex
                      )
                  )
              batch_requests = api_events.AddBatchRequest(
                  requests=list_requests
              )
              if batch_requests.requests:
                  res = task.session.send(batch_requests)
                  if res and not res.ok():
                      warning(
                          "failed logging metric task to backend ({:d} lines, {})".format(
                              len(batch_requests.requests),
                              str(res.meta),
                          )
                      )
      return True
  
imports: import json
  import os
  from functools import partial
  from logging import warning
  from multiprocessing.pool import ThreadPool
  from time import time
  from pathlib2 import Path
  from ...backend_api import Session
  from ...backend_api.services import events
  from ..base import InterfaceBase
  from ...config import config, deferred_config
  from ...debugging import get_logger
  from ...storage.helper import StorageHelper
  from .events import MetricsEventAdapter
  from ...utilities.process.mp import SingletonLock
label_desc: Use image node_id 12 for calling the Metrics obj's underlying member method code with example usage: obj.report_offline_session(cls, task, folder, iteration_offset) and returns: True, False