code: def test_zero_weights(self) -> None:
      # Test if weights = 0 for an update
      mse = MSEMetric(
          world_size=1,
          my_rank=0,
          batch_size=64,
          tasks=[DefaultTaskInfo],
          compute_mode=RecComputeMode.UNFUSED_TASKS_COMPUTATION,
          window_size=100,
          fused_update_limit=0,
          should_validate_update=True,
      )
      mse_computation = mse._metrics_computations[0]
  
      zero_weights = {
          k: torch.zeros_like(self.weights[k])
          for k in self.weights.keys()
      }
      mse.update(
          predictions=self.predictions,
          labels=self.labels,
          weights=zero_weights,
      )
      self.assertEqual(mse_computation.error_sum, torch.tensor(0.0))
      self.assertEqual(
          mse_computation.weighted_num_samples, torch.tensor(0.0)
      )
  
      res = mse.compute()
      self.assertEqual(
          res["mse-DefaultTask|lifetime_mse"], torch.tensor(0.0)
      )
      self.assertEqual(
          res["mse-DefaultTask|lifetime_rmse"], torch.tensor(0.0)
      )
  
      mse.update(
          predictions=self.predictions,
          labels=self.labels,
          weights=self.weights,
      )
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(mse_computation.error_sum, torch.tensor(0.0))
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          mse_computation.weighted_num_samples, torch.tensor(0.0)
      )
  
      res = mse.compute()
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          res["mse-DefaultTask|lifetime_mse"], torch.tensor(0.0)
      )
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          res["mse-DefaultTask|lifetime_rmse"], torch.tensor(0.0)
      )
  
      # Test if weights = 0 for one task of an update
      task_names = ["t1", "t2"]
      tasks = gen_test_tasks(task_names)
      _model_output = [
          gen_test_batch(
              label_name=task.label_name,
              prediction_name=task.prediction_name,
              weight_name=task.weight_name,
              batch_size=64,
          )
          for task in tasks
      ]
      model_output = {k: v for d in _model_output for k, v in d.items()}
      labels, predictions, weights, _ = parse_task_model_outputs(
          tasks, model_output
      )
      partial_zero_weights = {
          "t1": torch.zeros_like(weights["t1"]),
          "t2": weights["t2"],
      }
  
      ne = NEMetric(
          world_size=1,
          my_rank=0,
          batch_size=64,
          tasks=tasks,
          compute_mode=RecComputeMode.UNFUSED_TASKS_COMPUTATION,
          window_size=100,
          fused_update_limit=0,
          should_validate_update=True,
      )
      ne_computation = ne._metrics_computations
  
      ne.update(
          predictions=predictions,
          labels=labels,
          weights=partial_zero_weights,
      )
      self.assertEqual(
          ne_computation[0].cross_entropy_sum, torch.tensor(0.0)
      )
      self.assertEqual(
          ne_computation[0].weighted_num_samples, torch.tensor(0.0)
      )
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          ne_computation[1].cross_entropy_sum, torch.tensor(0.0)
      )
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          ne_computation[1].weighted_num_samples, torch.tensor(0.0)
      )
  
      res = ne.compute()
      self.assertEqual(res["ne-t1|lifetime_ne"], torch.tensor(0.0))
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(res["ne-t2|lifetime_ne"], torch.tensor(0.0))
  
      ne.update(
          predictions=predictions,
          labels=labels,
          weights=weights,
      )
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          ne_computation[0].cross_entropy_sum, torch.tensor(0.0)
      )
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(
          ne_computation[0].weighted_num_samples, torch.tensor(0.0)
      )
  
      res = ne.compute()
      # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but
      #  got `Tensor`.
      self.assertGreater(res["ne-t1|lifetime_ne"], torch.tensor(0.0))
  
file_path: torchrec/torchrec/metrics/tests/test_recmetric.py
imports: import unittest
  import torch
  from torchrec.metrics.metrics_config import DefaultTaskInfo
  from torchrec.metrics.model_utils import parse_task_model_outputs
  from torchrec.metrics.mse import MSEMetric
  from torchrec.metrics.ne import NEMetric
  from torchrec.metrics.rec_metric import RecComputeMode, RecMetric
  from torchrec.metrics.test_utils import gen_test_batch, gen_test_tasks
label_desc: Use image node_id 3 for calling the RecMetricTest obj's underlying member method code with example usage: obj.test_zero_weights() without return types