code: def _write_avg_gradient(self)->None:
          "Writes the average of the gradients to Tensorboard."
          avg_gradient = sum(x.data.mean() for x in self.gradients)/len(self.gradients)
          self._add_gradient_scalar('avg_gradient', scalar_value=avg_gradientf _write_avg_gradient(self)->None:
          "Writes the average of the gradients to Tensorboard."
          avg_gradient = sum(x.data.mean() for x in self.gradients)/len(self.gradients)
          self._add_gradient_scalar('avg_gradient', scalar_value=avg_gradient)
docs: Writes the average of the gradients to Tensorboard.