docstr: Helper method to log a scalar with VisdomLogger.
  
  Args:
      logger: visdom logger
      k: scalar name which is used to set window title and y-axis label
      v: scalar value, y-axis value
      event_name: Event name which is used to setup x-axis label. Valid events are from
          :class:`~ignite.engine.events.Events` or any `event_name` added by
          :meth:`~ignite.engine.engine.Engine.register_events`.
      global_step: global step, x-axis value
docstr_tok: ["Helper","method","to","log","a","scalar","with","VisdomLogger",".","Args",":","logger",":","visdom","logger","k",":","scalar","name","which","is","used","to","set","window","title","and","y-axis","label","v",":","scalar","value",",","y-axis","value","event_name",":","Event","name","which","is","used","to","setup","x-axis","label",".","Valid","events","are","from",":","class",":","`","~ignite.engine.events.Events","`","or","any","`","event_name","`","added","by",":","meth",":","`","~ignite.engine.engine.Engine.register_events","`",".","global_step",":","global","step",",","x-axis","value"]
code: def add_scalar(
      self,
      logger: VisdomLogger,
      k: str,
      v: Union[str, float, torch.Tensor],
      event_name: Any,
      global_step: int,
  ) -> None:
      """
      Helper method to log a scalar with VisdomLogger.
  
      Args:
          logger: visdom logger
          k: scalar name which is used to set window title and y-axis label
          v: scalar value, y-axis value
          event_name: Event name which is used to setup x-axis label. Valid events are from
              :class:`~ignite.engine.events.Events` or any `event_name` added by
              :meth:`~ignite.engine.engine.Engine.register_events`.
          global_step: global step, x-axis value
  
      """
      if k not in self.windows:
          self.windows[k] = {
              "win": None,
              "opts": {
                  "title": k,
                  "xlabel": str(event_name),
                  "ylabel": k,
                  "showlegend": self.show_legend,
              },
          }
  
      update = None if self.windows[k]["win"] is None else "append"
  
      kwargs = {
          "X": [global_step],
          "Y": [v],
          "env": logger.vis.env,  # type: ignore[attr-defined]
          "win": self.windows[k]["win"],
          "update": update,
          "opts": self.windows[k]["opts"],
          "name": k,
      }
  
      future = logger.executor.submit(logger.vis.line, **kwargs)
      if self.windows[k]["win"] is None:
          self.windows[k]["win"] = future.result()
  
imports: import os
  from typing import Any, Callable, cast, Dict, List, Optional, Union
  import torch
  import torch.nn
  from torch.optim import Optimizer
  from ignite.contrib.handlers.base_logger import BaseLogger, BaseOptimizerParamsHandler, BaseOutputHandler, BaseWeightsScalarHandler
  from ignite.engine import Engine, Events
  from ignite.handlers import global_step_from_engine
label_desc: Use image node_id 2 for calling the _BaseVisDrawer obj's underlying member method code with example usage: obj.add_scalar(logger, k, v, event_name, global_step) without return types