code: def _to_cov(x, n):
      """
      If x is a scalar, returns a covariance matrix generated from it
      as the identity matrix multiplied by x. The dimension will be nxn.
      If x is already a 2D numpy array then it is returned unchanged.
  
      Raises ValueError if not positive definite
      """
  
      if np.isscalar(x):
          if x < 0:
              raise ValueError("covariance must be > 0")
          return np.eye(n) * x
  
      x = np.atleast_2d(x)
      try:
          # quickly find out if we are positive definite
          np.linalg.cholesky(x)
      except:
          raise ValueError("covariance must be positive definit")
  
      return x
  
imports: from __future__ import absolute_import, division, unicode_literals
  import math
  from math import cos, sin
  import random
  import warnings
  import numpy
  from numpy.linalg import inv
  import scipy.linalg
  import scipy.sparse
  import scipy.sparse.linalg
  from scipy.stats import norm, multivariate_normal
label_desc: Use image node_id 23 for calling a global function with example usage: _to_cov(x, n) and returns: x, unknown