code: def _length_of_common_action_prefix(
      this: List[Event], other: List[Event]
  ) -> int:
      """Calculate number of actions that two conversations have in common."""
      num_common_actions = 0
      t_cleaned = cast(
          List[Union[ActionExecuted, UserUttered]],
          [e for e in this if e.type_name in {"user", "action"}],
      )
      o_cleaned = cast(
          List[Union[ActionExecuted, UserUttered]],
          [e for e in other if e.type_name in {"user", "action"}],
      )
  
      for i, e in enumerate(t_cleaned):
          o = o_cleaned[i]
          if i == len(o_cleaned):
              break
          elif isinstance(e, UserUttered) and isinstance(
              o, UserUttered
          ):
              continue
          elif (
              isinstance(e, ActionExecuted)
              and isinstance(o, ActionExecuted)
              and o.action_name == e.action_name
          ):
              num_common_actions += 1
          else:
              break
      return num_common_actions
  
imports: from collections import defaultdict, deque
  import random
  from typing import Any, Text, List, Deque, Dict, Optional, Set, TYPE_CHECKING, Union, cast
  import rasa.shared.utils.io
  from rasa.shared.constants import INTENT_MESSAGE_PREFIX
  from rasa.shared.core.constants import ACTION_LISTEN_NAME
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.events import UserUttered, ActionExecuted, Event
  from rasa.shared.core.generator import TrainingDataGenerator
  from rasa.shared.core.training_data.structures import StoryGraph, StoryStep
  from rasa.shared.nlu.constants import ENTITY_ATTRIBUTE_VALUE, INTENT, TEXT, ENTITY_ATTRIBUTE_TYPE, INTENT_NAME_KEY
label_desc: Use image node_id 12 for calling a global function with example usage: _length_of_common_action_prefix(this, other) and returns: num_common_actions