code: def generic_tree_test(
      experiment_name,
      parent_name=None,
      grand_parent_name=None,
      children_names=tuple(),
      grand_children_names=tuple(),
      node_trials=0,
      parent_trials=0,
      grand_parent_trials=0,
      children_trials=tuple(),
      grand_children_trials=tuple(),
      total_trials=0,
  ):
      """Test fetching of trials from experiments in the EVC tree.
  
      Parameters
      ----------
      experiment_name: str
          The name of the experiment that will be the main node for the tests.
      parent_name: str or None
          The name of the parent experiment, this will be used to fetch the trials from the parent
          experiment directly (not in EVC) for comparison.
      grand_parent_name: str or None
          The name of the grand parent experiment, this will be used to fetch the trials from the
          grand parent experiment directly (not in EVC) for comparison.
      children_names: list or str
          The names of the children experiments, this will be used to fetch the trials from the
          children experiments directly (not in EVC) for comparison.
      grand_children_names: list or str
          The names of the grand children experiments, this will be used to fetch the trials from the
          grand children experiments directly (not in EVC) for comparison. All grand children names
          may be included in the list even though they are associated to different children.
      node_trials: int,
          The number of trials that should be fetched from current node experiment.
      parent_trials: int,
          The number of trials that should be fetched from parent experiment (not using EVC tree).
      grand_parent_trials: int,
          The number of trials that should be fetched from grand parent experiment (not using EVC tree).
      children_trials: list of int,
          The number of trials that should be fetched from each children experiment (not using EVC tree).
      grand_children_trials: list of int,
          The number of trials that should be fetched from each grand children experiment (not using EVC tree).
      total_trials: int,
          The number of trials that should be fetched from current node experiment when fetching
          recursively from the EVC tree. This may not be equal to the sum of all trials in parent and
          children experiments depending on the adapters.
  
      """
  
      experiment = get_experiment(experiment_name)
      exp_node = experiment.node
  
      assert exp_node.item.name == experiment_name
  
      num_nodes = 1
  
      if parent_name:
          assert exp_node.parent.item.name == parent_name
          num_nodes += 1
      if grand_parent_name:
          assert exp_node.parent.parent.item.name == grand_parent_name
          num_nodes += 1
  
      assert len(exp_node.children) == len(children_names)
      if children_names:
          assert [
              child.item.name for child in exp_node.children
          ] == children_names
          num_nodes += len(children_names)
  
      if grand_children_names:
          grand_children = sum(
              (child.children for child in exp_node.children), []
          )
          assert [
              child.item.name for child in grand_children
          ] == grand_children_names
          num_nodes += len(grand_children_names)
  
      assert len(list(exp_node.root)) == num_nodes
  
      print("In node")
      for trial in experiment.fetch_trials():
          print(trial)
      assert len(experiment.fetch_trials()) == node_trials
      if parent_name:
          print("In parent")
          for trial in exp_node.parent.item.fetch_trials():
              print(trial)
          assert (
              len(exp_node.parent.item.fetch_trials()) == parent_trials
          )
      if grand_parent_name:
          print("In grand-parent")
          for trial in exp_node.parent.parent.item.fetch_trials():
              print(trial)
          assert (
              len(exp_node.parent.parent.item.fetch_trials())
              == grand_parent_trials
          )
  
      if children_names:
          print("In children")
          for trial in exp_node.children[0].item.fetch_trials():
              print(trial)
          assert [
              len(child.item.fetch_trials())
              for child in exp_node.children
          ] == children_trials
  
      if grand_children_names:
          grand_children = sum(
              (child.children for child in exp_node.children), []
          )
          all_trials = sum(
              (
                  child_node.item.fetch_trials()
                  for child_node in grand_children
              ),
              [],
          )
          print("In grand-children")
          for trial in all_trials:
              print(trial)
          assert [
              len(child.item.fetch_trials()) for child in grand_children
          ] == grand_children_trials
  
      print("with evc")
      for trial in experiment.fetch_trials(with_evc_tree=True):
          print(trial)
  
      assert (
          len(experiment.fetch_trials(with_evc_tree=True))
          == total_trials
      )
  
      all_ids = [
          trial.id
          for trial in experiment.fetch_trials(with_evc_tree=True)
      ]
      exp_ids = [
          trial.id
          for trial in experiment.fetch_trials(with_evc_tree=False)
      ]
  
      # Ensure all trials of experiment are fetched when fetching from all EVC
      # It could happen that some trials are missing if duplicates are incorrectly filtered out
      # from current node instead of from parent or child.
      assert set(exp_ids) - set(all_ids) == set()
  
imports: import pytest
  from orion.client import get_experiment
  from orion.testing.evc import build_child_experiment, build_grand_child_experiment, build_root_experiment, disable_duplication
label_desc: Use image node_id 1 for calling a global function with example usage: generic_tree_test(experiment_name, parent_name, grand_parent_name, children_names, grand_children_names, node_trials, parent_trials, grand_parent_trials, children_trials, grand_children_trials, total_trials) without return types