docstr: Adds a point to a multi-line plot given the plot name, the line name, and optionally the step (x coordinate).
docstr_tok: ["Adds","a","point","to","a","multi-line","plot","given","the","plot","name",",","the","line","name",",","and","optionally","the","step","(","x","coordinate",")","."]
code: def _add_point(
      tb_logger,
      plot_name: str,
      line_name: str,
      plot_value: Union[float, torch.Tensor],
      step: Optional[int],
  ) -> None:
      """Adds a point to a multi-line plot given the plot name, the line name, and optionally the step (x coordinate)."""
      if isinstance(plot_value, torch.Tensor):
          plot_value = plot_value.item()
  
      if step is None:
          if (
              plot_name in tb_logger.line_plot_buffer
              and line_name in tb_logger.line_plot_buffer[plot_name]
          ):
              x = (
                  tb_logger.line_plot_buffer[plot_name][line_name][-1][
                      0
                  ]
                  + 1.0
              )
          else:
              x = 0.0
      else:
          x = float(step)
  
      LocalCacheLogger._create_plots_and_append(
          tb_logger.line_plot_buffer,
          plot_name,
          line_name,
          x,
          plot_value,
      )
  
      if len(tb_logger.line_plot_buffer[plot_name][line_name]) >= 50:
          mean = float(
              torch.mean(
                  torch.FloatTensor(
                      [
                          float(p[1])
                          for p in tb_logger.line_plot_buffer[
                              plot_name
                          ][line_name]
                      ]
                  )
              ).item()
          )
          LocalCacheLogger._create_plots_and_append(
              tb_logger.line_plot_aggregated,
              plot_name,
              line_name,
              x,
              mean,
          )
          tb_logger.line_plot_buffer[plot_name][line_name].clear()
  
file_path: ReAgent/reagent/core/oss_tensorboard_logger.py
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  from pytorch_lightning.loggers import TensorBoardLogger
  from pytorch_lightning.utilities import rank_zero_only
label_desc: Use image node_id 2 for calling the LocalCacheLogger obj's underlying member method code with example usage: obj._add_point(tb_logger, plot_name, line_name, plot_value, step) without return types