def METHOD_NAME(data: Any, copy_mode: str) -> Any:
    """Returns the copied data using the copy mode specified.
    If no copy mode is provided, then it is inferred based on the type of the data.
    Args:
        data: The data to copy.
        copy_mode: The copy mode to use, one of "deepcopy", "copy" and "assign".
    Raises:
        DatasetError: If copy_mode is specified, but isn't valid
            (i.e: not one of deepcopy, copy, assign)
    Returns:
        The data copied according to the specified copy mode.
    """
    if copy_mode == "deepcopy":
        copied_data = copy.deepcopy(data)
    elif copy_mode == "copy":
        copied_data = data.copy()
    elif copy_mode == "assign":
        copied_data = data
    else:
        raise DatasetError(
            f"Invalid copy mode: {copy_mode}. "
            f"Possible values are: deepcopy, copy, assign."
        )
    return copied_data