class_docstr: Helper handler to log engine's output and/or metrics.
  
  Args:
      tag: common title for all produced plots. For example, "training"
      metric_names: list of metric names to plot or a string "all" to plot all available
          metrics.
      output_transform: output transform function to prepare `engine.state.output` as a number.
          For example, `output_transform = lambda output: output`
          This function can also return a dictionary, e.g `{"loss": loss1, "another_loss": loss2}` to label the plot
          with corresponding keys.
      global_step_transform: global step transform function to output a desired global step.
          Input of the function is `(engine, event_name)`. Output of function should be an integer.
          Default is None, global_step based on attached engine. If provided,
          uses function output as global_step. To setup global step from another engine, please use
          :meth:`~ignite.contrib.handlers.polyaxon_logger.global_step_from_engine`.
      state_attributes: list of attributes of the ``trainer.state`` to plot.
  
  Examples:
      .. code-block:: python
  
          from ignite.contrib.handlers.polyaxon_logger import *
  
          # Create a logger
          plx_logger = PolyaxonLogger()
  
          # Attach the logger to the evaluator on the validation dataset and log NLL, Accuracy metrics after
          # each epoch. We setup `global_step_transform=global_step_from_engine(trainer)` to take the epoch
          # of the `trainer`:
          plx_logger.attach(
              evaluator,
              log_handler=OutputHandler(
                  tag="validation",
                  metric_names=["nll", "accuracy"],
                  global_step_transform=global_step_from_engine(trainer)
              ),
              event_name=Events.EPOCH_COMPLETED
          )
          # or equivalently
          plx_logger.attach_output_handler(
              evaluator,
              event_name=Events.EPOCH_COMPLETED,
              tag="validation",
              metric_names=["nll", "accuracy"],
              global_step_transform=global_step_from_engine(trainer)
          )
  
      Another example, where model is evaluated every 500 iterations:
  
      .. code-block:: python
  
          from ignite.contrib.handlers.polyaxon_logger import *
  
          @trainer.on(Events.ITERATION_COMPLETED(every=500))
          def evaluate(engine):
              evaluator.run(validation_set, max_epochs=1)
  
          plx_logger = PolyaxonLogger()
  
          def global_step_transform(*args, **kwargs):
              return trainer.state.iteration
  
          # Attach the logger to the evaluator on the validation dataset and log NLL, Accuracy metrics after
          # every 500 iterations. Since evaluator engine does not have access to the training iteration, we
          # provide a global_step_transform to return the trainer.state.iteration for the global_step, each time
          # evaluator metrics are plotted on Polyaxon.
  
          plx_logger.attach_output_handler(
              evaluator,
              event_name=Events.EPOCH_COMPLETED,
              tag="validation",
              metrics=["nll", "accuracy"],
              global_step_transform=global_step_transform
          )
  
      Another example where the State Attributes ``trainer.state.alpha`` and ``trainer.state.beta``
      are also logged along with the NLL and Accuracy after each iteration:
  
      .. code-block:: python
  
          plx_logger.attach_output_handler(
              trainer,
              event_name=Events.ITERATION_COMPLETED,
              tag="training",
              metrics=["nll", "accuracy"],
              state_attributes=["alpha", "beta"],
          )
  
      Example of `global_step_transform`:
  
      .. code-block:: python
  
          def global_step_transform(engine, event_name):
              return engine.state.get_event_attrib_value(event_name)
  
  .. versionchanged:: 0.4.7
      accepts an optional list of `state_attributes`
class_docstr_tok: ["Helper","handler","to","log","engine","'s","output","and\/or","metrics",".","Args",":","tag",":","common","title","for","all","produced","plots",".","For","example",",","``","training","''","metric_names",":","list","of","metric","names","to","plot","or","a","string","``","all","''","to","plot","all","available","metrics",".","output_transform",":","output","transform","function","to","prepare","`","engine.state.output","`","as","a","number",".","For","example",",","`","output_transform","=","lambda","output",":","output","`","This","function","can","also","return","a","dictionary",",","e.g","`","{","``","loss","''",":","loss1",",","``","another_loss","''",":","loss2","}","`","to","label","the","plot","with","corresponding","keys",".","global_step_transform",":","global","step","transform","function","to","output","a","desired","global","step",".","Input","of","the","function","is","`","(","engine",",","event_name",")","`",".","Output","of","function","should","be","an","integer",".","Default","is","None",",","global_step","based","on","attached","engine",".","If","provided",",","uses","function","output","as","global_step",".","To","setup","global","step","from","another","engine",",","please","use",":","meth",":","`","~ignite.contrib.handlers.polyaxon_logger.global_step_from_engine","`",".","state_attributes",":","list","of","attributes","of","the","``","trainer.state","``","to","plot",".","Examples",":","..","code-block",":",":","python","from","ignite.contrib.handlers.polyaxon_logger","import","*","#","Create","a","logger","plx_logger","=","PolyaxonLogger","(",")","#","Attach","the","logger","to","the","evaluator","on","the","validation","dataset","and","log","NLL",",","Accuracy","metrics","after","#","each","epoch",".","We","setup","`","global_step_transform=global_step_from_engine","(","trainer",")","`","to","take","the","epoch","#","of","the","`","trainer","`",":","plx_logger.attach","(","evaluator",",","log_handler=OutputHandler","(","tag=","''","validation","''",",","metric_names=","[","``","nll","''",",","``","accuracy","''","]",",","global_step_transform=global_step_from_engine","(","trainer",")",")",",","event_name=Events.EPOCH_COMPLETED",")","#","or","equivalently","plx_logger.attach_output_handler","(","evaluator",",","event_name=Events.EPOCH_COMPLETED",",","tag=","''","validation","''",",","metric_names=","[","``","nll","''",",","``","accuracy","''","]",",","global_step_transform=global_step_from_engine","(","trainer",")",")","Another","example",",","where","model","is","evaluated","every","500","iterations",":","..","code-block",":",":","python","from","ignite.contrib.handlers.polyaxon_logger","import","*","@","trainer.on","(","Events.ITERATION_COMPLETED","(","every=500",")",")","def","evaluate","(","engine",")",":","evaluator.run","(","validation_set",",","max_epochs=1",")","plx_logger","=","PolyaxonLogger","(",")","def","global_step_transform","(","*","args",",","*","*","kwargs",")",":","return","trainer.state.iteration","#","Attach","the","logger","to","the","evaluator","on","the","validation","dataset","and","log","NLL",",","Accuracy","metrics","after","#","every","500","iterations",".","Since","evaluator","engine","does","not","have","access","to","the","training","iteration",",","we","#","provide","a","global_step_transform","to","return","the","trainer.state.iteration","for","the","global_step",",","each","time","#","evaluator","metrics","are","plotted","on","Polyaxon",".","plx_logger.attach_output_handler","(","evaluator",",","event_name=Events.EPOCH_COMPLETED",",","tag=","''","validation","''",",","metrics=","[","``","nll","''",",","``","accuracy","''","]",",","global_step_transform=global_step_transform",")","Another","example","where","the","State","Attributes","``","trainer.state.alpha","``","and","``","trainer.state.beta","``","are","also","logged","along","with","the","NLL","and","Accuracy","after","each","iteration",":","..","code-block",":",":","python","plx_logger.attach_output_handler","(","trainer",",","event_name=Events.ITERATION_COMPLETED",",","tag=","''","training","''",",","metrics=","[","``","nll","''",",","``","accuracy","''","]",",","state_attributes=","[","``","alpha","''",",","``","beta","''","]",",",")","Example","of","`","global_step_transform","`",":","..","code-block",":",":","python","def","global_step_transform","(","engine",",","event_name",")",":","return","engine.state.get_event_attrib_value","(","event_name",")","..","versionchanged",":",":","0.4.7","accepts","an","optional","list","of","`","state_attributes","`"]
code: def __init__(
      self,
      tag: str,
      metric_names: Optional[List[str]] = None,
      output_transform: Optional[Callable] = None,
      global_step_transform: Optional[
          Callable[[Engine, Union[str, Events]], int]
      ] = None,
      state_attributes: Optional[List[str]] = None,
  ):
      super(OutputHandler, self).__init__(
          tag,
          metric_names,
          output_transform,
          global_step_transform,
          state_attributes,
      )
  
file_path: ignite/ignite/contrib/handlers/polyaxon_logger.py
imports: from typing import Any, Callable, List, Optional, Union
  from torch.optim import Optimizer
  from ignite.contrib.handlers.base_logger import BaseLogger, BaseOptimizerParamsHandler, BaseOutputHandler
  from ignite.engine import Engine, Events
  from ignite.handlers import global_step_from_engine
label_desc: Use image node_id 1 to create a new OutputHandler object from inherited base classes: BaseOutputHandler with example: obj = OutputHandler(tag, metric_names, output_transform, global_step_transform, state_attributes)