code: def random_pipeline(
      verifier: GraphVerifier,
      node_factory: PipelineOptNodeFactory,
      requirements: PipelineComposerRequirements,
      max_depth: Optional[int] = None,
  ) -> OptGraph:
      max_depth = max_depth if max_depth else requirements.max_depth
      is_correct_graph = False
      graph = None
      n_iter = 0
      requirements = adjust_requirements(requirements)
  
      while not is_correct_graph:
          graph = OptGraph()
          if requirements.max_depth == 1:
              graph_root = node_factory.get_node(is_primary=True)
              graph.add_node(graph_root)
          else:
              graph_root = node_factory.get_node(is_primary=False)
              graph.add_node(graph_root)
              graph_growth(
                  graph,
                  graph_root,
                  node_factory,
                  requirements,
                  max_depth,
              )
  
          is_correct_graph = verifier(graph)
          n_iter += 1
          if n_iter > MAX_GRAPH_GEN_ATTEMPTS:
              raise ValueError(
                  f"Could not generate random graph for {n_iter} "
                  f"iterations with requirements {requirements}"
              )
      return graph
  
file_path: FEDOT/fedot/core/pipelines/random_pipeline_factory.py
imports: import random
  from copy import deepcopy
  from random import randint
  from typing import Optional
  from golem.core.constants import MAX_GRAPH_GEN_ATTEMPTS
  from golem.core.dag.graph_utils import distance_to_root_level
  from golem.core.dag.graph_verifier import GraphVerifier
  from golem.core.optimisers.graph import OptGraph, OptNode
  from golem.core.optimisers.random_graph_factory import RandomGraphFactory
  from fedot.core.pipelines.pipeline_composer_requirements import PipelineComposerRequirements
  from fedot.core.pipelines.pipeline_node_factory import PipelineOptNodeFactory
label_desc: Use image node_id 1 for calling a global function with example usage: random_pipeline(verifier, node_factory, requirements, max_depth) and returns: graph