class_docstr: Base class for all optimizers.
  .. warning::
      Parameters need to be specified as collections that have a deterministic
      ordering that is consistent between runs. Examples of objects that don't
      satisfy those properties are sets and iterators over values of dictionaries.
  Arguments:
      params (iterable): an iterable of :class:`torch.Tensor` s,
          :class:`dict` s, or :class:`crypten.CrypTensor`s. Specifies what Tensors
          should be optimized.
      defaults: (dict): a dict containing default values of optimization
          options (used when a parameter group doesn't specify them).
  
  Note: This optimizer is adapted from torch.optim.Optimizer to work with CrypTensors
docstr: Sets the gradients of all optimized parameters to zero or None.
  Args:
      set_to_none (bool): instead of setting to zero, set the grads to None.
          This will in general have lower memory footprint, and can modestly improve performance.
          However, it changes certain behaviors. For example:
          1. When the user tries to access a gradient and perform manual ops on it,
          a None attribute or a Tensor full of 0s will behave differently.
          2. If the user requests ``zero_grad(set_to_none=True)`` followed by a backward pass, ``.grad``\ s
          are guaranteed to be None for params that did not receive a gradient.
          3. ``crypten.optim`` optimizers have a different behavior if the gradient is 0 or None
          (in one case it does the step with a gradient of 0 and in the other it skips
          the step altogether).
  
  Note that CrypTen differs from PyTorch by setting the default value of `set_to_none` to True.
  This is because in CrypTen, it is often advantageous to set to None rather than to a zero-valued
  CrypTensor.
docstr_tok: ["Sets","the","gradients","of","all","optimized","parameters","to","zero","or","None",".","Args",":","set_to_none","(","bool",")",":","instead","of","setting","to","zero",",","set","the","grads","to","None",".","This","will","in","general","have","lower","memory","footprint",",","and","can","modestly","improve","performance",".","However",",","it","changes","certain","behaviors",".","For","example",":","1",".","When","the","user","tries","to","access","a","gradient","and","perform","manual","ops","on","it",",","a","None","attribute","or","a","Tensor","full","of","0s","will","behave","differently",".","2",".","If","the","user","requests","``","zero_grad","(","set_to_none=True",")","``","followed","by","a","backward","pass",",","``",".grad","``","\\","s","are","guaranteed","to","be","None","for","params","that","did","not","receive","a","gradient",".","3",".","``","crypten.optim","``","optimizers","have","a","different","behavior","if","the","gradient","is","0","or","None","(","in","one","case","it","does","the","step","with","a","gradient","of","0","and","in","the","other","it","skips","the","step","altogether",")",".","Note","that","CrypTen","differs","from","PyTorch","by","setting","the","default","value","of","`","set_to_none","`","to","True",".","This","is","because","in","CrypTen",",","it","is","often","advantageous","to","set","to","None","rather","than","to","a","zero-valued","CrypTensor","."]
code: def zero_grad(self, set_to_none=True):
      r"""Sets the gradients of all optimized parameters to zero or None.
      Args:
          set_to_none (bool): instead of setting to zero, set the grads to None.
              This will in general have lower memory footprint, and can modestly improve performance.
              However, it changes certain behaviors. For example:
              1. When the user tries to access a gradient and perform manual ops on it,
              a None attribute or a Tensor full of 0s will behave differently.
              2. If the user requests ``zero_grad(set_to_none=True)`` followed by a backward pass, ``.grad``\ s
              are guaranteed to be None for params that did not receive a gradient.
              3. ``crypten.optim`` optimizers have a different behavior if the gradient is 0 or None
              (in one case it does the step with a gradient of 0 and in the other it skips
              the step altogether).
  
      Note that CrypTen differs from PyTorch by setting the default value of `set_to_none` to True.
      This is because in CrypTen, it is often advantageous to set to None rather than to a zero-valued
      CrypTensor.
      """
      if set_to_none:
          for group in self.param_groups:
              for param in group["params"]:
                  param.grad = None
      else:
          for group in self.param_groups:
              for param in group["params"]:
                  if param.grad is not None:
                      param.grad -= param.grad
  
imports: import crypten
  import torch
  from torch.optim.optimizer import required
label_desc: Use image node_id 2 for calling the Optimizer obj's underlying member method code with example usage: obj.zero_grad(set_to_none) without return types