class_docstr: Writes entries directly to event files in the log_dir to be consumed by TensorBoard.
  
  The `SummaryWriter` class provides a high-level API to create an event file
  in a given directory and add summaries and events to it. The class updates the
  file contents asynchronously. This allows a training program to call methods
  to add data to the file directly from the training loop, without slowing down
  training.
class_docstr_tok: ["Writes","entries","directly","to","event","files","in","the","log_dir","to","be","consumed","by","TensorBoard",".","The","`","SummaryWriter","`","class","provides","a","high-level","API","to","create","an","event","file","in","a","given","directory","and","add","summaries","and","events","to","it",".","The","class","updates","the","file","contents","asynchronously",".","This","allows","a","training","program","to","call","methods","to","add","data","to","the","file","directly","from","the","training","loop",",","without","slowing","down","training","."]
docstr: Create a `SummaryWriter` that will write out events and summaries to the event file.
  
  Args:
      log_dir (str): Save directory location. Default is
        runs/**CURRENT_DATETIME_HOSTNAME**, which changes after each run.
        Use hierarchical folder structure to compare
        between runs easily. e.g. pass in 'runs/exp1', 'runs/exp2', etc.
        for each new experiment to compare across them.
      comment (str): Comment log_dir suffix appended to the default
        ``log_dir``. If ``log_dir`` is assigned, this argument has no effect.
      purge_step (int):
        When logging crashes at step :math:`T+X` and restarts at step :math:`T`,
        any events whose global_step larger or equal to :math:`T` will be
        purged and hidden from TensorBoard.
        Note that crashed and resumed experiments should have the same ``log_dir``.
      max_queue (int): Size of the queue for pending events and
        summaries before one of the 'add' calls forces a flush to disk.
        Default is ten items.
      flush_secs (int): How often, in seconds, to flush the
        pending events and summaries to disk. Default is every two minutes.
      filename_suffix (str): Suffix added to all event filenames in
        the log_dir directory. More details on filename construction in
        tensorboard.summary.writer.event_file_writer.EventFileWriter.
  
  Examples::
  
      from torch.utils.tensorboard import SummaryWriter
  
      # create a summary writer with automatically generated folder name.
      writer = SummaryWriter()
      # folder location: runs/May04_22-14-54_s-MacBook-Pro.local/
  
      # create a summary writer using the specified folder name.
      writer = SummaryWriter("my_experiment")
      # folder location: my_experiment
  
      # create a summary writer with comment appended.
      writer = SummaryWriter(comment="LR_0.1_BATCH_16")
      # folder location: runs/May04_22-14-54_s-MacBook-Pro.localLR_0.1_BATCH_16/
docstr_tok: ["Create","a","`","SummaryWriter","`","that","will","write","out","events","and","summaries","to","the","event","file",".","Args",":","log_dir","(","str",")",":","Save","directory","location",".","Default","is","runs\/","*","*","CURRENT_DATETIME_HOSTNAME","*","*",",","which","changes","after","each","run",".","Use","hierarchical","folder","structure","to","compare","between","runs","easily",".","e.g",".","pass","in","'runs\/exp1","'",",","'runs\/exp2","'",",","etc",".","for","each","new","experiment","to","compare","across","them",".","comment","(","str",")",":","Comment","log_dir","suffix","appended","to","the","default","``","log_dir","``",".","If","``","log_dir","``","is","assigned",",","this","argument","has","no","effect",".","purge_step","(","int",")",":","When","logging","crashes","at","step",":","math",":","`","T+X","`","and","restarts","at","step",":","math",":","`","T","`",",","any","events","whose","global_step","larger","or","equal","to",":","math",":","`","T","`","will","be","purged","and","hidden","from","TensorBoard",".","Note","that","crashed","and","resumed","experiments","should","have","the","same","``","log_dir","``",".","max_queue","(","int",")",":","Size","of","the","queue","for","pending","events","and","summaries","before","one","of","the","'add","'","calls","forces","a","flush","to","disk",".","Default","is","ten","items",".","flush_secs","(","int",")",":","How","often",",","in","seconds",",","to","flush","the","pending","events","and","summaries","to","disk",".","Default","is","every","two","minutes",".","filename_suffix","(","str",")",":","Suffix","added","to","all","event","filenames","in","the","log_dir","directory",".","More","details","on","filename","construction","in","tensorboard.summary.writer.event_file_writer.EventFileWriter",".","Examples",":",":","from","torch.utils.tensorboard","import","SummaryWriter","#","create","a","summary","writer","with","automatically","generated","folder","name",".","writer","=","SummaryWriter","(",")","#","folder","location",":","runs\/May04_22-14-54_s-MacBook-Pro.local\/","#","create","a","summary","writer","using","the","specified","folder","name",".","writer","=","SummaryWriter","(","``","my_experiment","''",")","#","folder","location",":","my_experiment","#","create","a","summary","writer","with","comment","appended",".","writer","=","SummaryWriter","(","comment=","''","LR_0.1_BATCH_16","''",")","#","folder","location",":","runs\/May04_22-14-54_s-MacBook-Pro.localLR_0.1_BATCH_16\/"]
code: def __init__(
      self,
      log_dir=None,
      comment="",
      purge_step=None,
      max_queue=10,
      flush_secs=120,
      filename_suffix="",
  ):
      """Create a `SummaryWriter` that will write out events and summaries to the event file.
  
      Args:
          log_dir (str): Save directory location. Default is
            runs/**CURRENT_DATETIME_HOSTNAME**, which changes after each run.
            Use hierarchical folder structure to compare
            between runs easily. e.g. pass in 'runs/exp1', 'runs/exp2', etc.
            for each new experiment to compare across them.
          comment (str): Comment log_dir suffix appended to the default
            ``log_dir``. If ``log_dir`` is assigned, this argument has no effect.
          purge_step (int):
            When logging crashes at step :math:`T+X` and restarts at step :math:`T`,
            any events whose global_step larger or equal to :math:`T` will be
            purged and hidden from TensorBoard.
            Note that crashed and resumed experiments should have the same ``log_dir``.
          max_queue (int): Size of the queue for pending events and
            summaries before one of the 'add' calls forces a flush to disk.
            Default is ten items.
          flush_secs (int): How often, in seconds, to flush the
            pending events and summaries to disk. Default is every two minutes.
          filename_suffix (str): Suffix added to all event filenames in
            the log_dir directory. More details on filename construction in
            tensorboard.summary.writer.event_file_writer.EventFileWriter.
  
      Examples::
  
          from torch.utils.tensorboard import SummaryWriter
  
          # create a summary writer with automatically generated folder name.
          writer = SummaryWriter()
          # folder location: runs/May04_22-14-54_s-MacBook-Pro.local/
  
          # create a summary writer using the specified folder name.
          writer = SummaryWriter("my_experiment")
          # folder location: my_experiment
  
          # create a summary writer with comment appended.
          writer = SummaryWriter(comment="LR_0.1_BATCH_16")
          # folder location: runs/May04_22-14-54_s-MacBook-Pro.localLR_0.1_BATCH_16/
  
      """
      torch._C._log_api_usage_once("tensorboard.create.summarywriter")
      if not log_dir:
          import socket
          from datetime import datetime
  
          current_time = datetime.now().strftime("%b%d_%H-%M-%S")
          log_dir = os.path.join(
              "runs",
              current_time + "_" + socket.gethostname() + comment,
          )
      self.log_dir = log_dir
      self.purge_step = purge_step
      self.max_queue = max_queue
      self.flush_secs = flush_secs
      self.filename_suffix = filename_suffix
  
      # Initialize the file writers, but they can be cleared out on close
      # and recreated later as needed.
      self.file_writer = self.all_writers = None
      self._get_file_writer()
  
      # Create default bins for histograms, see generate_testdata.py in tensorflow/tensorboard
      v = 1e-12
      buckets = []
      neg_buckets = []
      while v < 1e20:
          buckets.append(v)
          neg_buckets.append(-v)
          v *= 1.1
      self.default_bins = neg_buckets[::-1] + [0] + buckets
  
imports: import os
  import time
  from typing import List, Optional, Union, TYPE_CHECKING
  import torch
  from tensorboard.compat import tf
  from tensorboard.compat.proto import event_pb2
  from tensorboard.compat.proto.event_pb2 import Event, SessionLog
  from tensorboard.plugins.projector.projector_config_pb2 import ProjectorConfig
  from tensorboard.summary.writer.event_file_writer import EventFileWriter
  from ._convert_np import make_np
  from ._embedding import get_embedding_info, make_mat, make_sprite, make_tsv, write_pbtxt
  from ._onnx_graph import load_onnx_graph
  from ._pytorch_graph import graph
  from ._utils import figure_to_image
  from .summary import audio, custom_scalars, histogram, histogram_raw, hparams, image, image_boxes, mesh, pr_curve, pr_curve_raw, scalar, tensor_proto, text, video
label_desc: Use image node_id 1 to create a new SummaryWriter object  with example: obj = SummaryWriter(log_dir, comment, purge_step, max_queue, flush_secs, filename_suffix)