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 text using the summary writer. For example, if tag = "test",
  and metrics = { accuracy: 0.7, scores: { precision: 0.8, recall: 0.6 } },
  then under "tag=test" we will display "accuracy=0.7", and under
  "tag=test/scores" we will display "precision=0.8" and "recall=0.6" in
  TensorBoard.
  
  Args:
      tag (str): The tag name for the metric. If a field needs to be
          flattened further, it will be prepended as a prefix to the field
          name.
      metrics (Any): The metrics object/dict.
docstr_tok: ["Recursively","flattens","the","metrics","object","and","adds","each","field","name","and","value","as","a","text","using","the","summary","writer",".","For","example",",","if","tag","=","``","test","''",",","and","metrics","=","{","accuracy",":","0.7",",","scores",":","{","precision",":","0.8",",","recall",":","0.6","}","}",",","then","under","``","tag=test","''","we","will","display","``","accuracy=0.7","''",",","and","under","''","tag=test\/scores","''","we","will","display","``","precision=0.8","''","and","``","recall=0.6","''","in","TensorBoard",".","Args",":","tag","(","str",")",":","The","tag","name","for","the","metric",".","If","a","field","needs","to","be","flattened","further",",","it","will","be","prepended","as","a","prefix","to","the","field","name",".","metrics","(","Any",")",":","The","metrics","object\/dict","."]
code: def add_texts(self, tag, metrics):
      """
      Recursively flattens the metrics object and adds each field name and
      value as a text using the summary writer. For example, if tag = "test",
      and metrics = { accuracy: 0.7, scores: { precision: 0.8, recall: 0.6 } },
      then under "tag=test" we will display "accuracy=0.7", and under
      "tag=test/scores" we will display "precision=0.8" and "recall=0.6" in
      TensorBoard.
  
      Args:
          tag (str): The tag name for the metric. If a field needs to be
              flattened further, it will be prepended as a prefix to the field
              name.
          metrics (Any): The metrics object/dict.
      """
      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_text(
                  tag, f"{field_name}={field_value}"
              )
          elif hasattr(field_value, "_asdict"):
              self.add_texts(f"{tag}/{field_name}", field_value)
  
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 5 for calling the TensorBoardChannel obj's underlying member method code with example usage: obj.add_texts(tag, metrics) without return types