code: def test_optional_weights(self) -> None:
      ne1 = NEMetric(
          world_size=1,
          my_rank=0,
          batch_size=64,
          tasks=[DefaultTaskInfo],
          compute_mode=RecComputeMode.UNFUSED_TASKS_COMPUTATION,
          window_size=100,
          fused_update_limit=0,
      )
      ne2 = NEMetric(
          world_size=1,
          my_rank=1,
          batch_size=64,
          tasks=[DefaultTaskInfo],
          compute_mode=RecComputeMode.UNFUSED_TASKS_COMPUTATION,
          window_size=100,
          fused_update_limit=0,
      )
  
      default_weights = {
          k: torch.ones_like(self.labels[k])
          for k in self.weights.keys()
      }
      ne1.update(
          predictions=self.predictions,
          labels=self.labels,
          weights=default_weights,
      )
      ne2.update(
          predictions=self.predictions,
          labels=self.labels,
          weights=None,
      )
      ne1 = ne1._metrics_computations[0]
      ne2 = ne2._metrics_computations[0]
      self.assertTrue(ne1.cross_entropy_sum == ne2.cross_entropy_sum)
      self.assertTrue(
          ne1.weighted_num_samples == ne2.weighted_num_samples
      )
      self.assertTrue(ne1.pos_labels == ne2.pos_labels)
      self.assertTrue(ne1.neg_labels == ne2.neg_labels)
  
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 2 for calling the RecMetricTest obj's underlying member method code with example usage: obj.test_optional_weights() without return types