# Path: prompt_tuning/data/constants.py
# PREDICTION = "prediction"
# PREDICTION_TEXT = "prediction_pretokenized"
# INPUT_FIELD = "inputs"
# INPUT_TEXT = "inputs_pretokenized"
# TARGET_FIELD = "targets"
# TARGET_TEXT = "targets_pretokenized"
# CONTEXT_TEXT = "context"
# QUESTION_TEXT = "question"
# ANSWERS_TEXT = "answers"
# EXTRA_ID_0 = "<extra_id_0>"
# EQUIVALENT = "equivalent"
# DUPLICATE = "duplicate"
# 
# Path: prompt_tuning/data/utils.py
# def identity(x: Any, *args, **kwargs) -> Any:  # pylint: disable=unused-argument
# def task_mapping(tasks: Sequence[str],
#                  aliases: Optional[Mapping[str, str]]) -> Dict[str, int]:
# def remove_prefix(s: str, prefix: str) -> str:
# def remove_suffix(string: str, suffix: str) -> str:


from typing import Sequence, Mapping, Any, Union, Optional
from prompt_tuning.data import constants
from prompt_tuning.data import utils
# limitations under the License.

"""Custom Prompt Tuning postprocessors.

There are 3 main postprocessors. The first is the `postprocesses_with_examples`
which wraps any other postprocessor function and save the results (as well as
other provided keys) into a dict instead of just returning the postprocessed
result.

There is also a postprocessor that removes the <extra_id_0> from the beginning
of an output. (This is used for the span checkpoints).

There are also postprocessors that translate between the output labels for the
qqp and mrpc tasks, used in testing the transferability of models.
"""



# This function is a t5 postprocessor function so it needs to take *args and
# **kwargs, even though it doesn't use them itself.
def remove_extra_id_0(decoded_model_output: str, *args, **kwargs) -> str:  # pylint: disable=unused-argument
  """Possibly remove `<extra_id_0>` and leading white space."""
  return utils.remove_prefix(decoded_model_output,
                             constants.EXTRA_ID_0).lstrip()


def postprocess_with_examples(
    postprocess_func,
    decoded_model_output,
    prediction_field: str = constants.PREDICTION,

# Path: prompt_tuning/data/constants.py
# PREDICTION = "prediction"
# PREDICTION_TEXT = "prediction_pretokenized"
# INPUT_FIELD = "inputs"
# INPUT_TEXT = "inputs_pretokenized"
# TARGET_FIELD = "targets"
# TARGET_TEXT = "targets_pretokenized"
# CONTEXT_TEXT = "context"
# QUESTION_TEXT = "question"
# ANSWERS_TEXT = "answers"
# EXTRA_ID_0 = "<extra_id_0>"
# EQUIVALENT = "equivalent"
# DUPLICATE = "duplicate"
# 
# Path: prompt_tuning/data/utils.py
# def identity(x: Any, *args, **kwargs) -> Any:  # pylint: disable=unused-argument
# def task_mapping(tasks: Sequence[str],
#                  aliases: Optional[Mapping[str, str]]) -> Dict[str, int]:
# def remove_prefix(s: str, prefix: str) -> str:
# def remove_suffix(string: str, suffix: str) -> str:


# Path: prompt_tuning/data/postprocessors.py
from typing import Sequence, Mapping, Any, Union, Optional
from prompt_tuning.data import constants
from prompt_tuning.data import utils

# limitations under the License.

"""Custom Prompt Tuning postprocessors.

There are 3 main postprocessors. The first is the `postprocesses_with_examples`
which wraps any other postprocessor function and save the results (as well as
other provided keys) into a dict instead of just returning the postprocessed
result.

There is also a postprocessor that removes the <extra_id_0> from the beginning
of an output. (This is used for the span checkpoints).

There are also postprocessors that translate between the output labels for the
qqp and mrpc tasks, used in testing the transferability of models.
"""



# This function is a t5 postprocessor function so it needs to take *args and
# **kwargs, even though it doesn't use them itself.
def remove_extra_id_0(decoded_model_output: str, *args, **kwargs) -> str:  # pylint: disable=unused-argument
  """Possibly remove `<extra_id_0>` and leading white space."""
  return utils.remove_prefix(decoded_model_output,
                             constants.EXTRA_ID_0).lstrip()


def postprocess_with_examples(
    postprocess_func,
    decoded_model_output,
    prediction_field: str = constants.PREDICTION,

    prediction_text_field: str = constants.PREDICTION_TEXT,