"""Extract the duration in seconds from movie data.

This function attempts to extract the duration from the provided movie data dictionary. It checks for the duration in various possible fields and formats, converting it to seconds. The function handles durations provided directly in seconds, as a number in minutes, or in 'HH:MM:SS' or 'MM:SS' formats.

Args:
    movie_data (dict): A dictionary containing movie data, which may include duration information in various formats.

Returns:
    int or None: The duration in seconds if successfully extracted, otherwise None.

The function performs the following steps:
    1. Checks for 'duration_secs' key and uses its value directly if present.
    2. If 'duration_secs' is not present, checks for 'duration' key and attempts to parse its value:
        - If the value is a digit, assumes it represents minutes and converts to seconds.
        - If the value is in 'HH:MM:SS' or 'MM:SS' format, parses it accordingly to calculate the total seconds.
    3. Returns None if the duration cannot be extracted or parsed.
"""
You should write code starting with:
from typing import Dict, Optional

def extract_duration_from_data(movie_data: Dict[str, Any]) -> Optional[int]:
    # TODO: Implement this function based on the docstring.
    pass

