docstr: Calculates the truncated normal moments.
  
  Args:
    moment: The number for the moment.
  
  Returns:
    The value for the given moment.
  
  Uses the recurrence relation described in:
      http://www.smp.uq.edu.au/people/YoniNazarathy/teaching_projects
          /studentWork/EricOrjebin_TruncatedNormalMoments.pdf
docstr_tok: ["Calculates","the","truncated","normal","moments",".","Args",":","moment",":","The","number","for","the","moment",".","Returns",":","The","value","for","the","given","moment",".","Uses","the","recurrence","relation","described","in",":","http",":","\/\/www.smp.uq.edu.au\/people\/YoniNazarathy\/teaching_projects","\/studentWork\/EricOrjebin_TruncatedNormalMoments.pdf"]
code: def __getitem__(self, moment):
      """Calculates the truncated normal moments.
  
      Args:
        moment: The number for the moment.
  
      Returns:
        The value for the given moment.
  
      Uses the recurrence relation described in:
          http://www.smp.uq.edu.au/people/YoniNazarathy/teaching_projects
              /studentWork/EricOrjebin_TruncatedNormalMoments.pdf
      """
      assert moment > 0
      # The test case must ensure it can import scipy.stats before this point.
      import scipy.stats  # pylint: disable=g-import-not-at-top
  
      dist = scipy.stats.norm(loc=self.mean, scale=self.stddev)
      for k in range(len(self.memoized_moments), moment + 1):
          m_k_minus_2 = (
              self.memoized_moments[k - 2] if k > 1 else np.double(0.0)
          )
          m_k_minus_1 = self.memoized_moments[k - 1]
          numerator = np.power(self.maxval, k - 1) * dist.pdf(
              self.maxval
          ) - np.power(self.minval, k - 1) * dist.pdf(self.minval)
          denominator = dist.cdf(self.maxval) - dist.cdf(self.minval)
          m = (
              (k - 1) * self.stddev**2 * m_k_minus_2
              + self.mean * m_k_minus_1
              - self.stddev * numerator / denominator
          )
          assert abs(m) < 1e50  # ensure numerical accuracy
          self.memoized_moments.append(m)
      return self.memoized_moments[moment]
  
imports: import functools
  import math
  import timeit
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import backprop
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import stateless_random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 2 for calling the TruncatedNormalMoments obj's underlying member method code with example usage: obj.__getitem__(moment) and returns: self