code: def test_nested_multitask_wrapper():
      """Check that nested multitask wrappers work as expected."""
      classification_metric = BinaryAccuracy()
      regression_position_metric = MeanSquaredError()
      regression_size_metric = MeanAbsoluteError()
      multitask_metrics = MultitaskWrapper(
          {
              "Classification": BinaryAccuracy(),
              "Regression": MultitaskWrapper(
                  {
                      "Position": MeanSquaredError(),
                      "Size": MeanAbsoluteError(),
                  }
              ),
          }
      )
  
      multitask_preds = {
          "Classification": _classification_preds,
          "Regression": {
              "Position": _regression_preds,
              "Size": _regression_preds_2,
          },
      }
  
      multitask_targets = {
          "Classification": _classification_target,
          "Regression": {
              "Position": _regression_target,
              "Size": _regression_target_2,
          },
      }
  
      classification_metric.update(
          _classification_preds, _classification_target
      )
      regression_position_metric.update(
          _regression_preds, _regression_target
      )
      regression_size_metric.update(
          _regression_preds_2, _regression_target_2
      )
      multitask_metrics.update(multitask_targets, multitask_preds)
  
      classification_results = classification_metric.compute()
      regression_position_results = regression_position_metric.compute()
      regression_size_results = regression_size_metric.compute()
      regression_results = {
          "Position": regression_position_results,
          "Size": regression_size_results,
      }
      multitask_results = multitask_metrics.compute()
  
      assert _dict_results_same_as_individual_results(
          classification_results, regression_results, multitask_results
      )
  
file_path: torchmetrics/tests/unittests/wrappers/test_multitask.py
imports: import re
  import pytest
  import torch
  from torchmetrics import MetricCollection
  from torchmetrics.classification import BinaryAccuracy, BinaryF1Score
  from torchmetrics.regression import MeanAbsoluteError, MeanSquaredError
  from torchmetrics.wrappers import MultitaskWrapper
  from unittests import BATCH_SIZE, NUM_BATCHES
  from unittests.helpers import seed_all
label_desc: Use image node_id 8 for calling a global function with example usage: test_nested_multitask_wrapper() without return types