class_docstr: Class that takes a partially input convex neural network (picnn)
  as input and equips it with functions of logdet
  computation (both estimation and exact computation)
  
  This class is based on DeepConvexFlow of the CP-Flow
  repo (https://github.com/CW-Huang/CP-Flow)
  
  For details of the logdet estimator, see
  ``Convex potential flows: Universal probability distributions
  with optimal transport and convex optimization``
  
  Parameters
  ----------
  picnn
      A partially input convex neural network (picnn)
  dim
      Dimension of the input
  is_energy_score
      Indicates if energy score is used as the objective function
      If yes, the network is not required to be strictly convex,
      so we can just use the picnn
      otherwise, a quadratic term is added to the output of picnn
      to render it strictly convex
  m1
      Dimension of the Krylov subspace of the Lanczos tridiagonalization
      used in approximating H of logdet(H)
  m2
      Iteration number of the conjugate gradient algorithm
      used to approximate logdet(H)
  rtol
      relative tolerance of the conjugate gradient algorithm
  atol
      absolute tolerance of the conjugate gradient algorithm
class_docstr_tok: ["Class","that","takes","a","partially","input","convex","neural","network","(","picnn",")","as","input","and","equips","it","with","functions","of","logdet","computation","(","both","estimation","and","exact","computation",")","This","class","is","based","on","DeepConvexFlow","of","the","CP-Flow","repo","(","https",":","\/\/github.com\/CW-Huang\/CP-Flow",")","For","details","of","the","logdet","estimator",",","see","``","Convex","potential","flows",":","Universal","probability","distributions","with","optimal","transport","and","convex","optimization","``","Parameters","--","--","--","--","--","picnn","A","partially","input","convex","neural","network","(","picnn",")","dim","Dimension","of","the","input","is_energy_score","Indicates","if","energy","score","is","used","as","the","objective","function","If","yes",",","the","network","is","not","required","to","be","strictly","convex",",","so","we","can","just","use","the","picnn","otherwise",",","a","quadratic","term","is","added","to","the","output","of","picnn","to","render","it","strictly","convex","m1","Dimension","of","the","Krylov","subspace","of","the","Lanczos","tridiagonalization","used","in","approximating","H","of","logdet","(","H",")","m2","Iteration","number","of","the","conjugate","gradient","algorithm","used","to","approximate","logdet","(","H",")","rtol","relative","tolerance","of","the","conjugate","gradient","algorithm","atol","absolute","tolerance","of","the","conjugate","gradient","algorithm"]
code: def get_potential(
      self, x: torch.Tensor, context: Optional[torch.Tensor] = None
  ) -> torch.Tensor:
      n = x.size(0)
      output = self.picnn(x, context)
  
      if self.is_energy_score:
          return output
      else:
          return (
              F.softplus(self.w1) * output
              + F.softplus(self.w0)
              * (x.view(n, -1) ** 2).sum(1, keepdim=True)
              / 2
          )
  
file_path: gluonts/src/gluonts/torch/model/mqf2/icnn_utils.py
imports: from typing import Optional, Tuple, List, Union
  from cpflows.flows import SequentialFlow, DeepConvexFlow
  import torch
  import torch.nn.functional
  from torch.distributions.normal import Normal
label_desc: Use image node_id 2 for calling the DeepConvexNet obj's underlying member method code with example usage: obj.get_potential(x, context) and returns: output, unknown