code: def _validate_features(features: list, valid_features: list):
      """Raises exception if features list contains invalid features or duplicate features"""
      valid_features = set(valid_features)
      used_features = set()
      # validate features
      for feature in features:
          if isinstance(feature, tuple):
              feature_name = feature[0]
              feature_list = feature[1]
              feature_list_set = set(feature_list)
              if len(feature_list_set) != len(feature_list):
                  raise ValueError(
                      f"Feature list contains duplicate features:\n"
                      f"{feature_list}"
                  )
              for feature_in_list in feature_list:
                  if feature_in_list not in valid_features:
                      raise ValueError(
                          f"Feature does not exist in data: {feature_in_list}\n"
                          f"This feature came from the following feature set:\n"
                          f"{feature}\n"
                          f"Valid Features:\n"
                          f"{valid_features}"
                      )
          else:
              feature_name = feature
              if feature_name not in valid_features:
                  raise ValueError(
                      f"Feature does not exist in data: {feature_name}\n"
                      f"Valid Features:\n"
                      f"{valid_features}"
                  )
          if feature_name in used_features:
              raise ValueError(
                  f"Feature is present multiple times in feature list: {feature_name}"
              )
          used_features.add(feature_name)
  
imports: import logging
  import math
  import pickle
  import random
  import sys
  import time
  from typing import Callable, List, Tuple, Union
  import numpy
  import pandas
  import scipy.stats
  from numpy.typing import ArrayLike
  from pandas import DataFrame, Series
  from sklearn.model_selection import LeaveOneGroupOut, RepeatedKFold, RepeatedStratifiedKFold, train_test_split
  from autogluon.common.utils.resource_utils import ResourceManager
  from ..constants import BINARY, LARGE_DATA_THRESHOLD, MULTICLASS, MULTICLASS_UPPER_LIMIT, QUANTILE, REGRESS_THRESHOLD_LARGE_DATA, REGRESS_THRESHOLD_SMALL_DATA, REGRESSION, SOFTCLASS
  from ..metrics import Scorer, accuracy, pinball_loss, root_mean_squared_error
  from .miscs import warning_filter
label_desc: Use image node_id 21 for calling a global function with example usage: _validate_features(features, valid_features) without return types