```python:inference/core/workflows/core_steps/sinks/roboflow/dataset_upload/v1.py
import logging
import supervision as sv
from collections import OrderedDict
from concurrent.futures import ThreadPoolExecutor
from fastapi import BackgroundTasks
from inference.core.active_learning.cache_operations import return_strategy_credit, use_credit_of_matching_strategy
from inference.core.active_learning.core import prepare_image_to_registration
from inference.core.active_learning.entities import ImageDimensions, StrategyLimit, StrategyLimitType
from inference.core.cache.base import BaseCache
from inference.core.workflows.core_steps.common.utils import scale_sv_detections
from inference.core.workflows.execution_engine.entities.base import WorkflowImageData
from typing import Any, Dict, List, Literal, Optional, Tuple, Union
from uuid import uuid4

WORKSPACE_NAME_CACHE_EXPIRE = 900  # 15 min
TIMESTAMP_FORMAT = "%Y_%m_%d"
DUPLICATED_STATUS = "Duplicated image"
BatchCreationFrequency = Literal["never", "daily", "weekly", "monthly"]


def register_datapoint_at_roboflow(
    image: WorkflowImageData,
    prediction: Optional[Union[sv.Detections, dict]],
    target_project: str,
    usage_quota_name: str,
    persist_predictions: bool,
    minutely_usage_limit: int,
    hourly_usage_limit: int,
    daily_usage_limit: int,
    max_image_size: Tuple[int, int],
    compression_level: int,
    registration_tags: List[str],
    fire_and_forget: bool,
    labeling_batch_prefix: str,
    new_labeling_batch_frequency: BatchCreationFrequency,
    cache: BaseCache,
    background_tasks: Optional[BackgroundTasks],
    thread_pool_executor: Optional[ThreadPoolExecutor],
    api_key: str,
    image_name: Optional[str] = None,
    metadata: Optional[Dict[str, Any]] = None,
) -> Tuple[bool, str]:
    if fire_and_forget and background_tasks:
        background_tasks.add_task(
            execute_registration,
            image,
            prediction,
            target_project,
            persist_predictions,
            usage_quota_name,
            minutely_usage_limit,
            hourly_usage_limit,
            daily_usage_limit,
            max_image_size,
            compression_level,
            registration_tags,
            labeling_batch_prefix,
            new_labeling_batch_frequency,
            cache,
            api_key,
            image_name,
            metadata,
        )
        return False, "Element registration happens in the background task"
    if fire_and_forget and thread_pool_executor:
        thread_pool_executor.submit(
            execute_registration,
            image,
            prediction,
            target_project,
            persist_predictions,
            usage_quota_name,
            minutely_usage_limit,
            hourly_usage_limit,
            daily_usage_limit,
            max_image_size,
            compression_level,
            registration_tags,
            labeling_batch_prefix,
            new_labeling_batch_frequency,
            cache,
            api_key,
            image_name,
            metadata,
        )
        return False, "Element registration happens in the background task"
    return execute_registration(
        image,
        prediction,
        target_project,
        persist_predictions,
        usage_quota_name,
        minutely_usage_limit,
        hourly_usage_limit,
        daily_usage_limit,
        max_image_size,
        compression_level,
        registration_tags,
        labeling_batch_prefix,
        new_labeling_batch_frequency,
        cache,
        api_key,
        image_name,
        metadata,
    )


def execute_registration(
    image: WorkflowImageData,
    prediction: Optional[Union[sv.Detections, dict]],
    target_project: str,
    persist_predictions: bool,
    usage_quota_name: str,
    minutely_usage_limit: int,
    hourly_usage_limit: int,
    daily_usage_limit: int,
    max_image_size: Tuple[int, int],
    compression_level: int,
    registration_tags: List[str],
    labeling_batch_prefix: str,
    new_labeling_batch_frequency: BatchCreationFrequency,
    cache: BaseCache,
    api_key: str,
    image_name: Optional[str] = None,
    metadata: Optional[Dict[str, Any]] = None,
) -> Tuple[bool, str]:
    matching_strategies_limits = OrderedDict(
        {
            usage_quota_name: [
                StrategyLimit(
                    limit_type=StrategyLimitType.MINUTELY, value=minutely_usage_limit
                ),
                StrategyLimit(
                    limit_type=StrategyLimitType.HOURLY, value=hourly_usage_limit
                ),
                StrategyLimit(
                    limit_type=StrategyLimitType.DAILY, value=daily_usage_limit
                ),
            ]
        }
    )
    workspace_name = get_workspace_name(api_key=api_key, cache=cache)
    strategy_with_spare_credit = use_credit_of_matching_strategy(
        cache=cache,
        workspace=workspace_name,
        project=target_project,
        matching_strategies_limits=matching_strategies_limits,
    )
    if strategy_with_spare_credit is None:
        return False, "Registration skipped due to usage quota exceeded"
    credit_to_be_returned = False
    try:
        local_image_id = image_name if image_name else str(uuid4())
        encoded_image, scaling_factor = prepare_image_to_registration(
            image=image.numpy_image,
            desired_size=ImageDimensions(
                width=max_image_size[0], height=max_image_size[1]
            ),
            jpeg_compression_level=compression_level,
        )
        batch_name = generate_batch_name(
            labeling_batch_prefix=labeling_batch_prefix,
            new_labeling_batch_frequency=new_labeling_batch_frequency,
        )
        if isinstance(prediction, sv.Detections):
            prediction = scale_sv_detections(
                detections=prediction, scale=scaling_factor
            )
        status = register_datapoint(
            target_project=target_project,
            encoded_image=encoded_image,
            local_image_id=local_image_id,
            prediction=prediction if persist_predictions else None,
            api_key=api_key,
            batch_name=batch_name,
            tags=registration_tags,
            metadata=metadata,
        )
        if status == DUPLICATED_STATUS:
            credit_to_be_returned = True
        return False, status
    except Exception as error:
        credit_to_be_returned = True
        logging.exception("Failed to register datapoint on the Roboflow platform")
        return (
            True,
            f"Error while registration. Error type: {type(error)}. Details: {error}",
        )
    finally:
        if credit_to_be_returned:
            return_strategy_credit(
                cache=cache,
                workspace=workspace_name,
                project=target_project,
                strategy_name=strategy_with_spare_credit,
            )


RECREATION_INTERVAL2TIMESTAMP_GENERATOR = {
    "daily": generate_today_timestamp,
    "weekly": generate_start_timestamp_for_this_week,
    "monthly": generate_start_timestamp_for_this_month,
}
```