code: def _metric_protections(
      y: np.ndarray, y_hat: np.ndarray, weights: Optional[np.ndarray]
  ) -> None:
      assert (weights is None) or (
          np.sum(weights) > 0
      ), "Sum of weights cannot be 0"
      assert (weights is None) or (
          weights.shape == y.shape
      ), f"Wrong weight dimension weights.shape {weights.shape}, y.shape {y.shape}"
  
file_path: neuralforecast/neuralforecast/losses/numpy.py
imports: from typing import Optional, Union
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: _metric_protections(y, y_hat, weights) without return types