nodes: 0, module; 1, function_definition; 2, function_name:randn_ktensor; 3, parameters; 4, block; 5, identifier:shape; 6, identifier:rank; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, comment:# Check input.; 11, expression_statement; 12, comment:# Draw low-rank factor matrices with i.i.d. Gaussian elements.; 13, expression_statement; 14, return_statement; 15, identifier:norm; 16, None; 17, identifier:random_state; 18, None; 19, comment:"""
      Generates a random N-way tensor with rank R, where the entries are
      drawn from the standard normal distribution.
  
      Parameters
      ----------
      shape : tuple
          shape of the tensor
  
      rank : integer
          rank of the tensor
  
      norm : float or None, optional (defaults: None)
          If not None, the factor matrices are rescaled so that the Frobenius
          norm of the returned tensor is equal to ``norm``.
  
      random_state : integer, RandomState instance or None, optional (default ``None``)
          If integer, random_state is the seed used by the random number generator;
          If RandomState instance, random_state is the random number generator;
          If None, the random number generator is the RandomState instance used by np.random.
  
  
      Returns
      -------
      X : (I_1, ..., I_N) array_like
          N-way tensor with rank R.
  
      Example
      -------
      >>> # Create a rank-2 tensor of dimension 5x5x5:
      >>> import tensortools as tt
      >>> X = tt.randn_tensor((5,5,5), rank=2)
  
      """; 20, assignment; 21, assignment; 22, call; 23, identifier:rns; 24, call; 25, identifier:factors; 26, call; 27, identifier:_rescale_tensor; 28, argument_list; 29, identifier:_check_random_state; 30, argument_list; 31, identifier:KTensor; 32, argument_list; 33, identifier:factors; 34, identifier:norm; 35, identifier:random_state; 36, list_comprehension; 37, call; 38, for_in_clause; 39, attribute; 40, argument_list; 41, identifier:i; 42, identifier:shape; 43, identifier:rns; 44, identifier:standard_normal; 45, tuple; 46, identifier:i; 47, identifier:rank
code: def randn_ktensor(shape, rank, norm=None, random_state=None):
      """
      Generates a random N-way tensor with rank R, where the entries are
      drawn from the standard normal distribution.
  
      Parameters
      ----------
      shape : tuple
          shape of the tensor
  
      rank : integer
          rank of the tensor
  
      norm : float or None, optional (defaults: None)
          If not None, the factor matrices are rescaled so that the Frobenius
          norm of the returned tensor is equal to ``norm``.
  
      random_state : integer, RandomState instance or None, optional (default ``None``)
          If integer, random_state is the seed used by the random number generator;
          If RandomState instance, random_state is the random number generator;
          If None, the random number generator is the RandomState instance used by np.random.
  
  
      Returns
      -------
      X : (I_1, ..., I_N) array_like
          N-way tensor with rank R.
  
      Example
      -------
      >>> # Create a rank-2 tensor of dimension 5x5x5:
      >>> import tensortools as tt
      >>> X = tt.randn_tensor((5,5,5), rank=2)
  
      """
  
      # Check input.
      rns = _check_random_state(random_state)
  
      # Draw low-rank factor matrices with i.i.d. Gaussian elements.
      factors = KTensor([rns.standard_normal((i, rank)) for i in shape])
      return _rescale_tensor(factors, norm)