code: def _split_data(self):
      if self._data:
          return
  
      numpy.random.seed(self.split_seed)
      logger.debug("random seed set to: %i" % self.split_seed)
  
      self._data = self.get_data()
      gc.collect()
      if self.subsample:
          if self.stratify:
              logger.debug(
                  "subsampling stratified by `%s`: %s"
                  % (self.stratify, self.subsample)
              )
              ids = self._data[[self.stratify]].drop_duplicates()
              ids = ids.sample(self.subsample)
              self._data = pandas.merge(
                  self._data, ids, on=self.stratify
              )
          else:
              logger.debug("subsampling rows: %s" % self.subsample)
              self._data = self._data.sample(self.subsample)
          gc.collect()
  
      if self.stratify:
          ids = self._data[self.stratify].drop_duplicates()
  
          train_ids, validate_ids = train_test_split(
              ids,
              test_size=self.test_size,
              random_state=self.split_seed,
          )
          gc.collect()
          train_ids, test_ids = train_test_split(
              train_ids,
              test_size=self.test_size,
              random_state=self.split_seed,
          )
          gc.collect()
  
          rows = self._data[self.stratify].values
          self._training_data = self._data.iloc[
              numpy.isin(rows, train_ids.values)
          ]
          self._validation_data = self._data.iloc[
              numpy.isin(rows, validate_ids.values)
          ]
          self._test_data = self._data.iloc[
              numpy.isin(rows, test_ids.values)
          ]
      else:
          self._training_data, self._validation_data = train_test_split(
              self._data,
              test_size=self.test_size,
              random_state=self.split_seed,
          )
  
          self._training_data, self._test_data = train_test_split(
              self._training_data,
              test_size=self.test_size,
              random_state=self.split_seed,
          )
      gc.collect()
  
      self._data = None
      gc.collect()
  
      # It's import to reset these indexes after split so in case
      # these dataframes are copied, the missing split rows are
      # not re-materialized later full of nans.
      self._training_data.reset_index(drop=True, inplace=True)
      gc.collect()
      self._validation_data.reset_index(drop=True, inplace=True)
      gc.collect()
      self._test_data.reset_index(drop=True, inplace=True)
      gc.collect()
  
      logger.debug(
          "training: %i | validation: %i | test: %i"
          % (
              len(self._training_data),
              len(self._validation_data),
              len(self._test_data),
          )
      )
  
imports: from __future__ import absolute_import
  from abc import ABCMeta, abstractmethod
  from collections import OrderedDict, Iterable
  import gc
  import logging
  import multiprocessing
  import lore
  from lore.env import require
  from lore.util import timer, timed
  from lore.pipelines import Observations
  import numpy
  import pandas
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 23 for calling the Base obj's underlying member method code with example usage: obj._split_data() without return types