class_docstr: Computes a scaling factor as the weighted average absolute value along
  dimension ``dim``, and scales the data accordingly.
  
  Parameters
  ----------
  dim
      dimension along which to compute the scale
  keepdim
      controls whether to retain dimension ``dim`` (of length 1) in the
      scale tensor, or suppress it.
  default_scale
      default scale that is used for elements that are constantly zero
  minimum_scale
      minimum possible scale that is used for any item.
class_docstr_tok: ["Computes","a","scaling","factor","as","the","weighted","average","absolute","value","along","dimension","``","dim","``",",","and","scales","the","data","accordingly",".","Parameters","--","--","--","--","--","dim","dimension","along","which","to","compute","the","scale","keepdim","controls","whether","to","retain","dimension","``","dim","``","(","of","length","1",")","in","the","scale","tensor",",","or","suppress","it",".","default_scale","default","scale","that","is","used","for","elements","that","are","constantly","zero","minimum_scale","minimum","possible","scale","that","is","used","for","any","item","."]
code: def __call__(
      self, data: torch.Tensor, observed_indicator: torch.Tensor
  ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
      # shape: (N, [C], T=1)
      ts_sum = (
          (data * observed_indicator).abs().sum(self.dim, keepdim=True)
      )
      num_observed = observed_indicator.sum(self.dim, keepdim=True)
  
      scale = ts_sum / torch.clamp(num_observed, min=1)
  
      # If `default_scale` is provided, we use it, otherwise we use the scale
      # of the batch.
      if self.default_scale is None:
          batch_sum = ts_sum.sum(dim=0)
          batch_observations = torch.clamp(num_observed.sum(0), min=1)
          default_scale = torch.squeeze(batch_sum / batch_observations)
      else:
          default_scale = self.default_scale * torch.ones_like(scale)
  
      # apply default scale where there are no observations
      scale = torch.where(
          num_observed > 0,
          scale,
          default_scale,
      )
  
      # ensure the scale is at least `self.minimum_scale`
      scale = torch.clamp(scale, min=self.minimum_scale)
  
      scaled_data = data / scale
  
      if not self.keepdim:
          scale = scale.squeeze(dim=self.dim)
  
      loc = torch.zeros_like(scale)
  
      return scaled_data, loc, scale
  
file_path: gluonts/src/gluonts/torch/scaler.py
imports: from __future__ import annotations
  from typing import Optional
  import torch
  from gluonts.core.component import validated
label_desc: Use image node_id 2 for calling the MeanScaler obj's underlying member method code with example usage: obj.__call__(data, observed_indicator) and returns: scaled_data,  loc,  scale