code: def sample_data(data, features_grid):
      """
      Samples from the data number of rows specified in
      the ``n_outputs`` argument. In case if ``n_outputs > n_samples``
      then sample will be with replacement.
  
      Parameters
      ----------
      data : matrix ``(n_samples, n_features)``
          Matrix where each row is a data sample.
  
      features_grid : tuple
          Tuple that defines shape of the feature grid.
  
      Returns
      -------
      matrix ``(n_features, n_outputs)``
      """
      n_outputs = np.prod(features_grid)
      n_samples, n_features = data.shape
  
      with_replacement = n_samples < n_outputs
      indices = np.random.choice(
          n_samples, n_outputs, replace=with_replacement
      )
  
      return data[indices].T
  
imports: from __future__ import division
  from collections import namedtuple
  import six
  import numpy
  from numpy.linalg import norm
  from neupy import init
  from neupy.utils import as_tuple, format_data
  from neupy.algorithms import Kohonen
  from neupy.exceptions import WeightInitializationError
  from neupy.algorithms.associative.base import BaseAssociative
  from neupy.core.properties import BaseProperty, TypedListProperty, ChoiceProperty, NumberProperty, ParameterProperty, IntProperty
  from .randomized_pca import randomized_pca
  from .neighbours import find_step_scaler_on_rect_grid, find_neighbours_on_rect_grid, find_neighbours_on_hexagon_grid, find_step_scaler_on_hexagon_grid
label_desc: Use image node_id 4 for calling a global function with example usage: sample_data(data, features_grid) and returns: data