code: def test_random_split_by_session(self):
      num_sessions = (
          tc.activity_classifier.util._MIN_NUM_SESSIONS_FOR_SPLIT
      )
      _load_data(
          self,
          num_examples=10000,
          max_num_sessions=num_sessions,
          randomize_num_sessions=False,
          enforce_all_sessions=True,
      )
  
      (
          train,
          valid,
      ) = tc.activity_classifier.util.random_split_by_session(
          self.data, self.session_id, self.fraction, self.seed
      )
  
      train_num_sessions = len(train[self.session_id].unique())
      train_frac = float(train_num_sessions / num_sessions)
      expected_frac = self.fraction
  
      self.assertAlmostEqual(
          train_frac,
          expected_frac,
          places=1,
          msg="Got {} train sessions out of {}, which is {:.3f}, and not the expected {}".format(
              train_num_sessions,
              num_sessions,
              train_frac,
              expected_frac,
          ),
      )
  
      valid_num_sessions = len(valid[self.session_id].unique())
      valid_frac = float(valid_num_sessions / num_sessions)
      expected_valid_frac = 1.0 - self.fraction
  
      self.assertAlmostEqual(
          valid_frac,
          expected_valid_frac,
          places=1,
          msg="Got {} train sessions out of {}, which is {:.3f}, and not the expected {}".format(
              valid_num_sessions,
              num_sessions,
              valid_frac,
              expected_valid_frac,
          ),
      )
  
      train_sessions_set = set(train[self.session_id].unique())
      valid_sessions_set = set(valid[self.session_id].unique())
  
      self.assertTrue(
          train_sessions_set.isdisjoint(valid_sessions_set),
          "After train-test split, the train and validation sets should not include the same sessions",
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import unittest
  import turicreate
  import random
  import tempfile
  import math
  import numpy
  from numbers import Number
  from .None import util
  import pytest
  from turicreate.toolkits._internal_utils import _mac_ver
  from turicreate.toolkits._main import ToolkitError
  import uuid
label_desc: Use image node_id 4 for calling the ActivityClassifierAutoValdSetTest obj's underlying member method code with example usage: obj.test_random_split_by_session() without return types