def METHOD_NAME(
    self,
    task_id: Optional[str] = None,
    task_run_id: Optional[str] = None,
    requester_id: Optional[str] = None,
    assignment_id: Optional[str] = None,
    unit_index: Optional[int] = None,
    provider_type: Optional[str] = None,
    task_type: Optional[str] = None,
    agent_id: Optional[str] = None,
    worker_id: Optional[str] = None,
    sandbox: Optional[bool] = None,
    status: Optional[str] = None,
) -> List[Unit]:
    """
    Uses caching to offset the cost of the most common queries. Defers
    to the underlying DB for anything outside of those cases.
    """
    # Finding units is the most common small DB call to be optimized, as
    # every assignment has multiple units. Thus, we try to break up the
    # units to be queried by assignment, ensuring the most commonly
    # queried edge is improved.
    if assignment_id is not None:
        if all(
            v is None
            for v in [
                task_id,
                task_run_id,
                requester_id,
                unit_index,
                provider_type,
                task_type,
                agent_id,
                worker_id,
                sandbox,
                status,
            ]
        ):
            units = self._assignment_to_unit_mapping.get(assignment_id)
            if units is None:
                units = super().METHOD_NAME(assignment_id=assignment_id)
                self._assignment_to_unit_mapping[assignment_id] = units
            return units
    # Any other cases are less common and more complicated, and so we don't cache
    return super().METHOD_NAME(
        task_id=task_id,
        task_run_id=task_run_id,
        requester_id=requester_id,
        assignment_id=assignment_id,
        unit_index=unit_index,
        provider_type=provider_type,
        task_type=task_type,
        agent_id=agent_id,
        worker_id=worker_id,
        sandbox=sandbox,
        status=status,
    )