class_docstr: This class tests accuracy of distributions provided by random sampling in crypten.
class_docstr_tok: ["This","class","tests","accuracy","of","distributions","provided","by","random","sampling","in","crypten","."]
docstr: Checks that the function `func` returns a distribution with the expected
  size, mean, and variance.
  
  Arguments:
      func - A function that takes a size and returns a random sample as a CrypTensor
      expected_mean - The expected mean for the distribution returned by function `func`
      expected_variance - The expected variance for the distribution returned by function `func
      lb - An expected lower bound on samples from the given distribution. Use None if -Inf.
      ub - An expected uppder bound on samples from the given distribution. Use None if +Inf.
docstr_tok: ["Checks","that","the","function","`","func","`","returns","a","distribution","with","the","expected","size",",","mean",",","and","variance",".","Arguments",":","func","-","A","function","that","takes","a","size","and","returns","a","random","sample","as","a","CrypTensor","expected_mean","-","The","expected","mean","for","the","distribution","returned","by","function","`","func","`","expected_variance","-","The","expected","variance","for","the","distribution","returned","by","function","`","func","lb","-","An","expected","lower","bound","on","samples","from","the","given","distribution",".","Use","None","if","-Inf",".","ub","-","An","expected","uppder","bound","on","samples","from","the","given","distribution",".","Use","None","if","+Inf","."]
code: def _check_distribution(
      self, func, expected_mean, expected_variance, lb=None, ub=None
  ):
      """
      Checks that the function `func` returns a distribution with the expected
      size, mean, and variance.
  
      Arguments:
          func - A function that takes a size and returns a random sample as a CrypTensor
          expected_mean - The expected mean for the distribution returned by function `func`
          expected_variance - The expected variance for the distribution returned by function `func
          lb - An expected lower bound on samples from the given distribution. Use None if -Inf.
          ub - An expected uppder bound on samples from the given distribution. Use None if +Inf.
      """
      name = func.__name__
      for size in [(10000,), (1000, 10), (101, 11, 11)]:
          sample = func(size)
  
          self.assertTrue(
              sample.size() == size,
              "Incorrect size for %s distribution" % name,
          )
  
          plain_sample = sample.get_plain_text().float()
          mean = plain_sample.mean()
          var = plain_sample.var()
          self.assertTrue(
              math.isclose(
                  mean, expected_mean, rel_tol=1e-1, abs_tol=1e-1
              ),
              "incorrect variance for %s distribution: %f"
              % (name, mean),
          )
          self.assertTrue(
              math.isclose(
                  var, expected_variance, rel_tol=1e-1, abs_tol=1e-1
              ),
              "incorrect variance for %s distribution: %f"
              % (name, var),
          )
          if lb is not None:
              self.assertTrue(
                  plain_sample.ge(lb).all(),
                  "Sample detected below lower bound for %s distribution"
                  % name,
              )
          if ub is not None:
              self.assertTrue(
                  plain_sample.le(ub).all(),
                  "Sample detected below lower bound for %s distribution"
                  % name,
              )
  
file_path: CrypTen/test/test_distributions.py
imports: import math
  import crypten
  import torch
  from crypten.config import cfg
  from test.multiprocess_test_case import MultiProcessTestCase
label_desc: Use image node_id 1 for calling the TestDistributions obj's underlying member method code with example usage: obj._check_distribution(func, expected_mean, expected_variance, lb, ub) without return types