def is_thm_included(thm, splits, library_tags):
  """Decides whether the theorem is included in the selection.

  This function can be used for filtering for theorems belonging to
  the allowed splits and library tags.

  Args:
    thm: Theorem object to be decided for inclusion.
    splits: Of type List[proof_assistant_pb2.Theorem.Split], the list of
      training splits for which tasks should be generated for.
    library_tags: List of strings for the library tags to be processed. If
      empty, then all library tags are allowed.

  Returns:
    Boolean indicating whether the theorem is included in the selection.
  """
  return thm.training_split in splits and (
      (not library_tags or (set(thm.library_tag) & library_tags)))