class_docstr: "
  This class implement the second order optimizer - KFAC, which uses Kronecker factor products of inputs and the gradients to
  get the approximate inverse fisher matrix, which is used to update the model parameters. Presently this optimizer works only
  on liner and 2D convolution layers. If you want to know more details about KFAC, please check the paper [1]_ and [2]_.
  
  References:
  -----------
  [1] Martens, James, and Roger Grosse. Optimizing Neural Networks with Kronecker-Factored Approximate Curvature.
  arXiv:1503.05671, arXiv, 7 June 2020. arXiv.org, http://arxiv.org/abs/1503.05671.
  [2] Grosse, Roger, and James Martens. A Kronecker-Factored Approximate Fisher Matrix for Convolution Layers.
  arXiv:1602.01407, arXiv, 23 May 2016. arXiv.org, http://arxiv.org/abs/1602.01407.
class_docstr_tok: ["``","This","class","implement","the","second","order","optimizer","-","KFAC",",","which","uses","Kronecker","factor","products","of","inputs","and","the","gradients","to","get","the","approximate","inverse","fisher","matrix",",","which","is","used","to","update","the","model","parameters",".","Presently","this","optimizer","works","only","on","liner","and","2D","convolution","layers",".","If","you","want","to","know","more","details","about","KFAC",",","please","check","the","paper","[","1","]","_","and","[","2","]","_.","References",":","--","--","--","--","--","-","[","1","]","Martens",",","James",",","and","Roger","Grosse",".","Optimizing","Neural","Networks","with","Kronecker-Factored","Approximate","Curvature",".","arXiv:1503.05671",",","arXiv",",","7","June","2020.","arXiv.org",",","http",":","\/\/arxiv.org\/abs\/1503.05671",".","[","2","]","Grosse",",","Roger",",","and","James","Martens",".","A","Kronecker-Factored","Approximate","Fisher","Matrix","for","Convolution","Layers",".","arXiv:1602.01407",",","arXiv",",","23","May","2016.","arXiv.org",",","http",":","\/\/arxiv.org\/abs\/1602.01407","."]
docstr: Checks the memory layout of the input tensor and changes it to contiguous type.
  
  Parameters:
  -----------
  x: torch.Tensor
      The input tensor to be made contiguous in memory, if it is not so.
  
  Return:
  -------
  torch.Tensor
      Tensor with contiguous memory
docstr_tok: ["Checks","the","memory","layout","of","the","input","tensor","and","changes","it","to","contiguous","type",".","Parameters",":","--","--","--","--","--","-","x",":","torch.Tensor","The","input","tensor","to","be","made","contiguous","in","memory",",","if","it","is","not","so",".","Return",":","--","--","--","-","torch.Tensor","Tensor","with","contiguous","memory"]
code: def try_contiguous(self, x: torch.Tensor) -> torch.Tensor:
      """
      Checks the memory layout of the input tensor and changes it to contiguous type.
  
      Parameters:
      -----------
      x: torch.Tensor
          The input tensor to be made contiguous in memory, if it is not so.
  
      Return:
      -------
      torch.Tensor
          Tensor with contiguous memory
      """
      if not x.is_contiguous():
          x = x.contiguous()
  
      return x
  
file_path: deepchem/deepchem/models/torch_models/kfac_optimizer.py
imports: import math
  from typing import Optional, Callable, Dict, Tuple, List, Union
label_desc: Use image node_id 2 for calling the KFACOptimizer obj's underlying member method code with example usage: obj.try_contiguous(x) and returns: x