class_docstr: TensorBoardChannel defines how to format and report the result of a PyText
  job to TensorBoard.
  
  Attributes:
      summary_writer: An instance of the TensorBoard SummaryWriter class, or
          an object that implements the same interface.
          https://pytorch.org/docs/stable/tensorboard.html
      metric_name: The name of the default metric to display on the
          TensorBoard dashboard, defaults to "accuracy"
      train_step: The training step count
class_docstr_tok: ["TensorBoardChannel","defines","how","to","format","and","report","the","result","of","a","PyText","job","to","TensorBoard",".","Attributes",":","summary_writer",":","An","instance","of","the","TensorBoard","SummaryWriter","class",",","or","an","object","that","implements","the","same","interface",".","https",":","\/\/pytorch.org\/docs\/stable\/tensorboard.html","metric_name",":","The","name","of","the","default","metric","to","display","on","the","TensorBoard","dashboard",",","defaults","to","``","accuracy","''","train_step",":","The","training","step","count"]
docstr: Recursively flattens the metrics object and adds each field name and
  value as a scalar for the corresponding epoch using the summary writer.
  
  Args:
      prefix (str): The tag prefix for the metric. Each field name in the
          metrics object will be prepended with the prefix.
      metrics (Any): The metrics object.
docstr_tok: ["Recursively","flattens","the","metrics","object","and","adds","each","field","name","and","value","as","a","scalar","for","the","corresponding","epoch","using","the","summary","writer",".","Args",":","prefix","(","str",")",":","The","tag","prefix","for","the","metric",".","Each","field","name","in","the","metrics","object","will","be","prepended","with","the","prefix",".","metrics","(","Any",")",":","The","metrics","object","."]
code: def add_scalars(self, prefix, metrics, epoch):
      """
      Recursively flattens the metrics object and adds each field name and
      value as a scalar for the corresponding epoch using the summary writer.
  
      Args:
          prefix (str): The tag prefix for the metric. Each field name in the
              metrics object will be prepended with the prefix.
          metrics (Any): The metrics object.
      """
      if hasattr(metrics, "_asdict"):
          metrics = metrics._asdict()
      for field_name, field_value in metrics.items():
          if isinstance(field_value, (int, float)):
              self.summary_writer.add_scalar(
                  f"{prefix}/{field_name}", field_value, epoch
              )
          elif hasattr(field_value, "_asdict") or isinstance(
              field_value, dict
          ):
              self.add_scalars(
                  f"{prefix}/{field_name}", field_value, epoch
              )
  
imports: import csv
  import sys
  import traceback
  from typing import Tuple
  import numpy
  import torch
  from numpy import linalg
  from pytext.common.constants import Stage
  from pytext.utils.file_io import PathManager
  from torch.utils.tensorboard import SummaryWriter
label_desc: Use image node_id 6 for calling the TensorBoardChannel obj's underlying member method code with example usage: obj.add_scalars(prefix, metrics, epoch) without return types