class_docstr: SSL Specific variant of the Classy Vision tensorboard hook
class_docstr_tok: ["SSL","Specific","variant","of","the","Classy","Vision","tensorboard","hook"]
docstr: Called at the end of every epoch if the tensorboard hook is
  enabled.
  Log model parameters and/or parameter gradients as set by user
  in the tensorboard configuration. Also resents the CUDA memory counter.
docstr_tok: ["Called","at","the","end","of","every","epoch","if","the","tensorboard","hook","is","enabled",".","Log","model","parameters","and\/or","parameter","gradients","as","set","by","user","in","the","tensorboard","configuration",".","Also","resents","the","CUDA","memory","counter","."]
code: def on_phase_end(self, task: "tasks.ClassyTask") -> None:
      """
      Called at the end of every epoch if the tensorboard hook is
      enabled.
      Log model parameters and/or parameter gradients as set by user
      in the tensorboard configuration. Also resents the CUDA memory counter.
      """
      # Log train/test accuracy
      if is_primary():
          phase_type = "Training" if task.train else "Testing"
          for meter in task.meters:
              for metric_name, vals in meter.value.items():
                  for i, val in vals.items():
                      tag_name = f"{phase_type}/{meter.name}_{metric_name}_Output_{i}"
                      self.tb_writer.add_scalar(
                          tag=tag_name,
                          scalar_value=round(val, 5),
                          global_step=task.train_phase_idx,
                      )
      if not (self.log_params or self.log_params_gradients):
          return
  
      if is_primary() and task.train:
          # Log the weights and bias at the end of the epoch
          if self.log_params:
              for name, parameter in task.base_model.named_parameters():
                  self.tb_writer.add_histogram(
                      f"Parameters/{name}",
                      parameter,
                      global_step=task.train_phase_idx,
                  )
          # Log the parameter gradients at the end of the epoch
          if self.log_params_gradients:
              for name, parameter in task.base_model.named_parameters():
                  if parameter.grad is not None:
                      try:
                          self.tb_writer.add_histogram(
                              f"Gradients/{name}",
                              parameter.grad,
                              global_step=task.train_phase_idx,
                          )
                      except ValueError:
                          logging.info(
                              f"Gradient histogram empty for {name}, "
                              f"iteration {task.iteration}. Unable to "
                              f"log gradient."
                          )
  
          # Reset the GPU Memory counter
          if torch.cuda.is_available():
              torch.cuda.reset_max_memory_allocated()
              torch.cuda.reset_max_memory_cached()
  
file_path: vissl/vissl/hooks/tensorboard_hook.py
imports: import logging
  import torch
  from classy_vision import tasks
  from classy_vision.generic.distributed_util import is_primary
  from classy_vision.hooks.classy_hook import ClassyHook
  from vissl.utils.activation_statistics import ActivationStatistics, ActivationStatisticsMonitor, ActivationStatisticsObserver
label_desc: Use image node_id 6 for calling the SSLTensorboardHook obj's underlying member method code with example usage: obj.on_phase_end(task) without return types