code: def _validate_foreach_constraints(graph):
      def traverse_graph(node, state):
          if node.type == "foreach" and node.is_inside_foreach:
              raise NotSupportedException(
                  "Step *%s* is a foreach step called within a foreach step. "
                  "This type of graph is currently not supported with Airflow."
                  % node.name
              )
  
          if node.type == "foreach":
              state["foreach_stack"] = [node.name]
  
          if node.type in ("start", "linear", "join", "foreach"):
              if node.type == "linear" and node.is_inside_foreach:
                  state["foreach_stack"].append(node.name)
  
              if (
                  "foreach_stack" in state
                  and len(state["foreach_stack"]) > 2
              ):
                  raise NotSupportedException(
                      "The foreach step *%s* created by step *%s* needs to have an immediate join step. "
                      "Step *%s* is invalid since it is a linear step with a foreach. "
                      "This type of graph is currently not supported with Airflow."
                      % (
                          state["foreach_stack"][1],
                          state["foreach_stack"][0],
                          state["foreach_stack"][-1],
                      )
                  )
  
              traverse_graph(graph[node.out_funcs[0]], state)
  
          elif node.type == "split":
              for func in node.out_funcs:
                  traverse_graph(graph[func], state)
  
      traverse_graph(graph["start"], {})
  
imports: import base64
  import os
  import re
  import sys
  from hashlib import sha1
  from metaflow import current, decorators
  from metaflow._vendor import click
  from metaflow.exception import MetaflowException, MetaflowInternalError
  from metaflow.package import MetaflowPackage
  from metaflow.plugins.aws.step_functions.production_token import load_token, new_token, store_token
  from metaflow.plugins.kubernetes.kubernetes_decorator import KubernetesDecorator
  from metaflow.util import get_username, to_bytes, to_unicode
  from .airflow import Airflow
  from .exception import AirflowException, NotSupportedException
label_desc: Use image node_id 6 for calling a global function with example usage: _validate_foreach_constraints(graph) without return types