class_docstr: Differentiable Stochastic Gradient Descent.
  
  DifferentiableSGD performs the same optimization step as SGD, but instead
  of updating parameters in-place, it saves updated parameters in new
  tensors, so that the gradient of functions of new parameters can flow back
  to the pre-updated parameters.
  
  Args:
      module (torch.nn.module): A torch module whose parameters needs to be
          optimized.
      lr (float): Learning rate of stochastic gradient descent.
class_docstr_tok: ["Differentiable","Stochastic","Gradient","Descent",".","DifferentiableSGD","performs","the","same","optimization","step","as","SGD",",","but","instead","of","updating","parameters","in-place",",","it","saves","updated","parameters","in","new","tensors",",","so","that","the","gradient","of","functions","of","new","parameters","can","flow","back","to","the","pre-updated","parameters",".","Args",":","module","(","torch.nn.module",")",":","A","torch","module","whose","parameters","needs","to","be","optimized",".","lr","(","float",")",":","Learning","rate","of","stochastic","gradient","descent","."]
docstr: Take an optimization step.
docstr_tok: ["Take","an","optimization","step","."]
code: def step(self):
      """Take an optimization step."""
      memo = set()
  
      def update(module):
          for child in module.children():
              if child not in memo:
                  memo.add(child)
                  update(child)
  
          params = list(module.named_parameters())
          for name, param in params:
              # Skip descendant modules' parameters.
              if "." not in name:
                  if param.grad is None:
                      continue
  
                  # Original SGD uses param.grad.data
                  new_param = param.add(param.grad, alpha=-self.lr)
  
                  del module._parameters[
                      name
                  ]  # pylint: disable=protected-access # noqa: E501
                  setattr(module, name, new_param)
                  module._parameters[
                      name
                  ] = new_param  # pylint: disable=protected-access # noqa: E501
  
      update(self.module)
  
label_desc: Use image node_id 2 for calling the DifferentiableSGD obj's underlying member method code with example usage: obj.step() without return types