class_docstr: Implements a natural gradient descent step.
  It **can only** be used in conjunction with a :obj:`~gpytorch.variational._NaturalVariationalDistribution`.
  
  .. seealso::
      - :obj:`gpytorch.variational.NaturalVariationalDistribution`
      - :obj:`gpytorch.variational.TrilNaturalVariationalDistribution`
      - The `natural gradient descent tutorial
        <examples/04_Variational_and_Approximate_GPs/Natural_Gradient_Descent.ipynb>`_
        for use instructions.
  
  Example:
      >>> ngd_optimizer = torch.optim.NGD(model.variational_parameters(), num_data=train_y.size(0), lr=0.1)
      >>> ngd_optimizer.zero_grad()
      >>> mll(gp_model(input), target).backward()
      >>> ngd_optimizer.step()
class_docstr_tok: ["Implements","a","natural","gradient","descent","step",".","It","*","*","can","only","*","*","be","used","in","conjunction","with","a",":","obj",":","`","~gpytorch.variational._NaturalVariationalDistribution","`",".","..","seealso",":",":","-",":","obj",":","`","gpytorch.variational.NaturalVariationalDistribution","`","-",":","obj",":","`","gpytorch.variational.TrilNaturalVariationalDistribution","`","-","The","`","natural","gradient","descent","tutorial","<","examples\/04_Variational_and_Approximate_GPs\/Natural_Gradient_Descent.ipynb",">","`","_","for","use","instructions",".","Example",":",">",">",">","ngd_optimizer","=","torch.optim.NGD","(","model.variational_parameters","(",")",",","num_data=train_y.size","(","0",")",",","lr=0.1",")",">",">",">","ngd_optimizer.zero_grad","(",")",">",">",">","mll","(","gp_model","(","input",")",",","target",")",".backward","(",")",">",">",">","ngd_optimizer.step","(",")"]
code: def __init__(
      self,
      params: Iterable[Union[torch.nn.Parameter, dict]],
      num_data: int,
      lr: float = 0.1,
  ):
      self.num_data = num_data
      super().__init__(params, defaults=dict(lr=lr))
  
imports: from typing import Callable, Iterable, Optional, Union
  import torch
label_desc: Use image node_id 1 to create a new NGD object from inherited base classes: torch.optim with example: obj = NGD(params, num_data, lr)