original_docstring: Zero out the gradient for a group of parameters.
      Note: copied from torch.optim.optimizer.
docstring: Zero out the gradient for a group of parameters.
docstring_tokens: Zero out the gradient for a group of parameters .
code: def _zero_grad_group_helper(group, set_to_none):
      """Zero out the gradient for a group of parameters.
      Note: copied from torch.optim.optimizer."""
      for param in group:
          if param.grad is not None:
              if set_to_none:
                  param.grad = None
              else:
                  if param.grad.grad_fn is not None:
                      param.grad.detach_()
                  else:
                      param.grad.requires_grad_(False)
                  param.grad.zero_()
code_tokens: def _zero_grad_group_helper ( group , set_to_none ) : for param in group : if param . grad is not None : if set_to_none : param . grad = None else : if param . grad . grad_fn is not None : param . grad . detach_ ( ) else : param . grad . requires_grad_ ( False ) param . grad . zero_ ( )
short_docstring: Zero out the gradient for a group of parameters.
short_docstring_tokens: Zero out the gradient for a group of parameters .
comment: """Zero out the gradient for a group of parameters.
      Note: copied from torch.optim.optimizer."""