from typing import Type
from typing import Any
import types
from typing import List
import inspect


def get_all_subclasses_in_module(
    parent_class: Type[Any],
    module: types.ModuleType,
    exclude_private: bool = True,
    exclude_abstract: bool = False) -> List[Type[Any]]:
  """Returns all classes derived from parent_class in the module.

  Args:
    parent_class: Class object from which the subclasses must be derived.
    module: Module to scan for subclasses.
    exclude_private: If True, do not include private classes.
    exclude_abstract: If True, do not include abstract classes.

  Returns:
    Subclasses of parent_class defined in the module.
  """
  subclasses = []
  for name, member in inspect.getmembers(module):
    if (inspect.isclass(member)
        and (not exclude_abstract or not inspect.isabstract(member))
        and (not exclude_private or not name.startswith("_"))
        and issubclass(member, parent_class)):
      subclasses.append(member)
  return subclasses