#
# Copyright 2020-present by A. Mathis Group and contributors. All rights reserved.
#
# This project and all its files are licensed under GNU AGPLv3 or later version. 
# A copy is included in dlc2action/LICENSE.AGPL.
#
"""Self-supervised learning.

Self-supervised learning tasks in `dlc2action` are implemented in the form of the `base_ssl.SSLConstructor`
abstract class.
In order to create a new task you need to define four things: a data *transformation*, a network *module*, a *loss
function* and the *type* of the task that defines interaction with the base network.

The *transformation* is applied to model input data at runtime to generate the SSL input and target from input data.
It receives the target data as a feature dictionary, so complex generalised transformations can be defined easily.
The SSL input and target should also be returned in similarly formatted dictionaries so that augmentations can be
applied to them correctly. If you are using the `dlc2action.task.task_dispatcher.TaskDispatcher`
(or `dlc2action.project.project.Project`) interface, they will be regarded
differently according to the type of the task:

- `'ssl_input'`: if the input generated by transformation is None an error will be raised; if the generated target
    is None it will be replaced by the unmodified input data,
- `'ssl_target'`: the input generated by transformation will be disregarded; if the generated target is None it will
    be replaced by the unmodified input data,
- `'contrastive'`, `'contrastive_2layers'`: if the transformation returns None for the input, the input will be created by the transformer as
    an augmentation of the input data; if the target is `None` it will stay `None`,

You can also set these rules manually with the `keep_target_none` and `generate_ssl_input` parameters of the
transformers.

The SSL *module* is stacked with the base network feature extraction module as described above. The *loss function*
takes SSL output and SSL target as input and returns a loss value (all operations must be differentiable by `torch`).
The available types are described at `dlc2action.ssl.base_ssl.SSLConstructor`.
"""

from dlc2action.ssl.contrastive import *
from dlc2action.ssl.masked import *
