code: def get_train_valid_sets(
      x, y, validation_data, validation_split, shuffle=True
  ):
      """Generate validation and training datasets from whole dataset tensors
  
      Args:
          x (torch.Tensor): Data tensor for dataset
          y (torch.Tensor): Label tensor for dataset
          validation_data ((torch.Tensor, torch.Tensor)): Optional validation data (x_val, y_val) to be
              used instead of splitting x and y tensors
          validation_split (float): Fraction of dataset to be used for validation
          shuffle (bool): If True randomize tensor order before splitting else do not randomize
  
      Returns:
          Training and validation datasets
      """
  
      valset = None
  
      if validation_data is not None:
          x_val, y_val = validation_data
      elif isinstance(validation_split, float):
          x, y, x_val, y_val = train_valid_splitter(
              x, y, validation_split, shuffle=shuffle
          )
      else:
          x_val, y_val = None, None
  
      trainset = TensorDataset(x, y)
      if x_val is not None and y_val is not None:
          valset = TensorDataset(x_val, y_val)
  
      return trainset, valset
  
file_path: torchbearer/torchbearer/cv_utils.py
imports: import math
  import torch
  from torch.utils.data import TensorDataset, Dataset
  import random
label_desc: Use image node_id 2 for calling a global function with example usage: get_train_valid_sets(x, y, validation_data, validation_split, shuffle) and returns: trainset,  valset