code: def _check_if_stacking_is_permitted(
      f_primitive: PrimitiveBase,
      primitive_class: Type[PrimitiveBase],
      primitive_stack_on_self: bool,
      tuple_primitive_stack_on: Tuple[Type[PrimitiveBase]],
  ):
      if primitive_stack_on_self and isinstance(
          f_primitive, primitive_class
      ):
          return True
      if tuple_primitive_stack_on is None or isinstance(
          f_primitive,
          tuple_primitive_stack_on,
      ):
          return True
      if f_primitive.base_of is None:
          return True
      if primitive_class in f_primitive.base_of:
          return True
      return False
  
imports: import functools
  import logging
  import operator
  import warnings
  from collections import defaultdict
  from typing import Any, DefaultDict, Dict, List, Tuple, Type
  from woodwork.column_schema import ColumnSchema
  from woodwork.logical_types import Boolean, BooleanNullable
  from featuretools import primitives
  from featuretools.entityset.entityset import LTI_COLUMN_NAME
  from featuretools.entityset.relationship import RelationshipPath
  from featuretools.feature_base import AggregationFeature, DirectFeature, FeatureBase, GroupByTransformFeature, IdentityFeature, TransformFeature
  from featuretools.feature_base.cache import CacheType, feature_cache
  from featuretools.feature_base.utils import is_valid_input
  from featuretools.primitives.base import AggregationPrimitive, PrimitiveBase, TransformPrimitive
  from featuretools.primitives.options_utils import filter_groupby_matches_by_options, filter_matches_by_options, generate_all_primitive_options, ignore_dataframe_for_primitive
  from featuretools.utils.gen_utils import Library, camel_and_title_to_snake
label_desc: Use image node_id 5 for calling a global function with example usage: _check_if_stacking_is_permitted(f_primitive, primitive_class, primitive_stack_on_tuple_primitive_stack_on) and returns: False, True, True, True, True