docstr: The squared coefficient of variation of a sample.
  Useful as a loss to encourage a positive distribution to be more uniform.
  Epsilons added for numerical stability.
  Returns 0 for an empty Tensor.
  Args:
  x: a `Tensor`.
  Returns:
  a `Scalar`.
docstr_tok: ["The","squared","coefficient","of","variation","of","a","sample",".","Useful","as","a","loss","to","encourage","a","positive","distribution","to","be","more","uniform",".","Epsilons","added","for","numerical","stability",".","Returns","0","for","an","empty","Tensor",".","Args",":","x",":","a","`","Tensor","`",".","Returns",":","a","`","Scalar","`","."]
code: def cv_squared(self, x):
      """The squared coefficient of variation of a sample.
      Useful as a loss to encourage a positive distribution to be more uniform.
      Epsilons added for numerical stability.
      Returns 0 for an empty Tensor.
      Args:
      x: a `Tensor`.
      Returns:
      a `Scalar`.
      """
      eps = 1e-10
      # if only num_expert = 1
      if x.shape[0] == 1:
          return torch.Tensor([0])
      return x.float().var() / (x.float().mean() ** 2 + eps)
  
file_path: smart-moe/fmoe/gates/noisy_gate.py
imports: from .base_gate import BaseGate
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.distributions.normal import Normal
  import math
label_desc: Use image node_id 5 for calling the NoisyGate obj's underlying member method code with example usage: obj.cv_squared(x) and returns: unknown, torch