docstr: Send the mean and std of all parameters and gradients to tensorboard, as well
  as logging the average gradient norm.
docstr_tok: ["Send","the","mean","and","std","of","all","parameters","and","gradients","to","tensorboard",",","as","well","as","logging","the","average","gradient","norm","."]
code: def _parameter_and_gradient_statistics_to_tensorboard(
      self, epoch, batch_grad_norm  # pylint: disable=invalid-name
  ):
      """
      Send the mean and std of all parameters and gradients to tensorboard, as well
      as logging the average gradient norm.
      """
      # Log parameter values to Tensorboard
      for name, param in self._model.named_parameters():
          self._tensorboard.add_train_scalar(
              "parameter_mean/" + name, param.data.mean(), epoch
          )
          self._tensorboard.add_train_scalar(
              "parameter_std/" + name, param.data.std(), epoch
          )
          if param.grad is not None:
              if is_sparse(param.grad):
                  # pylint: disable=protected-access
                  grad_data = param.grad.data._values()
              else:
                  grad_data = param.grad.data
  
              # skip empty gradients
              if (
                  torch.prod(torch.tensor(grad_data.shape)).item() > 0
              ):  # pylint: disable=not-callable
                  self._tensorboard.add_train_scalar(
                      "gradient_mean/" + name, grad_data.mean(), epoch
                  )
                  self._tensorboard.add_train_scalar(
                      "gradient_std/" + name, grad_data.std(), epoch
                  )
              else:
                  # no gradient for a parameter with sparse gradients
                  logger.info(
                      "No gradient for %s, skipping tensorboard logging.",
                      name,
                  )
      # norm of gradients
      if batch_grad_norm is not None:
          self._tensorboard.add_train_scalar(
              "gradient_norm", batch_grad_norm, epoch
          )
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import logging
  import os
  import shutil
  import time
  import re
  import datetime
  import traceback
  import torch
  import torch.optim.lr_scheduler
  from torch.nn.parallel import replicate, parallel_apply
  from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import peak_memory_mb, gpu_memory_mb
  from allennlp.common.tqdm import Tqdm
  from allennlp.data.instance import Instance
  from allennlp.data.iterators.data_iterator import DataIterator
  from allennlp.models.model import Model
  from allennlp.nn import util
  from allennlp.training.learning_rate_schedulers import LearningRateScheduler
  from allennlp.training.optimizers import Optimizer
label_desc: Use image node_id 10 for calling the Trainer obj's underlying member method code with example usage: obj._parameter_and_gradient_statistics_to_tensorboard(epoch, batch_grad_norm) without return types