code: def _baseline_ergas(
      preds: Tensor,
      target: Tensor,
      ratio: float = 4,
      reduction: str = "elementwise_mean",
  ) -> Tensor:
      """Baseline implementation of Erreur Relative Globale Adimensionnelle de Synthèse."""
      reduction_options = ("elementwise_mean", "sum", "none")
      if reduction not in reduction_options:
          raise ValueError(
              f"reduction has to be one of {reduction_options}, got: {reduction}."
          )
      # reshape to (batch_size, channel, height*width)
      b, c, h, w = preds.shape
      sk_preds = preds.reshape(b, c, h * w)
      sk_target = target.reshape(b, c, h * w)
      # compute rmse per band
      diff = sk_preds - sk_target
      sum_squared_error = torch.sum(diff * diff, dim=2)
      rmse_per_band = torch.sqrt(sum_squared_error / (h * w))
      mean_target = torch.mean(sk_target, dim=2)
      # compute ergas score
      ergas_score = (
          100
          * ratio
          * torch.sqrt(
              torch.sum((rmse_per_band / mean_target) ** 2, dim=1) / c
          )
      )
      # reduction
      if reduction == "sum":
          return torch.sum(ergas_score)
      if reduction == "elementwise_mean":
          return torch.mean(ergas_score)
      return ergas_score
  
imports: from functools import partial
  from typing import NamedTuple
  import pytest
  import torch
  from torch import Tensor
  from torchmetrics.functional.image.ergas import error_relative_global_dimensionless_synthesis
  from torchmetrics.image.ergas import ErrorRelativeGlobalDimensionlessSynthesis
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from unittests import BATCH_SIZE, NUM_BATCHES
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 1 for calling a global function with example usage: _baseline_ergas(preds, target, ratio, reduction) and returns: ergas_score, torch, torch