class_docstr: Helper handler to log engine's output and/or metrics
class_docstr_tok: ["Helper","handler","to","log","engine","'s","output","and\/or","metrics"]
code: def __init__(
      self,
      tag: str,
      metric_names: Optional[Union[str, 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,
  ):
      if metric_names is not None:
          if not (
              isinstance(metric_names, list)
              or (
                  isinstance(metric_names, str)
                  and metric_names == "all"
              )
          ):
              raise TypeError(
                  f"metric_names should be either a list or equal 'all', got {type(metric_names)} instead."
              )
  
      if output_transform is not None and not callable(
          output_transform
      ):
          raise TypeError(
              f"output_transform should be a function, got {type(output_transform)} instead."
          )
  
      if (
          output_transform is None
          and metric_names is None
          and state_attributes is None
      ):
          raise ValueError(
              "Either metric_names, output_transform or state_attributes should be defined"
          )
  
      if global_step_transform is not None and not callable(
          global_step_transform
      ):
          raise TypeError(
              f"global_step_transform should be a function, got {type(global_step_transform)} instead."
          )
  
      if global_step_transform is None:
  
          def global_step_transform(
              engine: Engine, event_name: Union[str, Events]
          ) -> int:
              return engine.state.get_event_attrib_value(event_name)
  
      self.tag = tag
      self.metric_names = metric_names
      self.output_transform = output_transform
      self.global_step_transform = global_step_transform
      self.state_attributes = state_attributes
  
imports: import numbers
  import warnings
  from abc import ABCMeta, abstractmethod
  from collections import OrderedDict
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import torch
  import torch.nn
  from torch.optim import Optimizer
  from ignite.engine import Engine, Events, EventsList, State
  from ignite.engine.events import CallableEventWithFilter, RemovableEventHandle
label_desc: Use image node_id 1 to create a new BaseOutputHandler object from inherited base classes: BaseHandler with example: obj = BaseOutputHandler(tag, metric_names, output_transform, global_step_transform, state_attributes)