code: def test_binary_1d():
      """Test balancing transformer on single-task dataset without explicit task dimension."""
      n_samples = 6
      n_features = 3
      np.random.seed(123)
      X = np.random.rand(n_samples, n_features)
      y = np.array([1, 1, 0, 0, 0, 0])
      w = np.ones((n_samples,))
      dataset = dc.data.NumpyDataset(X, y, w)
  
      duplicator = dc.trans.DuplicateBalancingTransformer(
          dataset=dataset
      )
      dataset = duplicator.transform(dataset)
      # Check that we have length 8 now with duplication
      assert len(dataset) == 8
      X_t, y_t, w_t, ids_t = (
          dataset.X,
          dataset.y,
          dataset.w,
          dataset.ids,
      )
      # Check shapes
      assert X_t.shape == (8, n_features)
      assert y_t.shape == (8,)
      assert w_t.shape == (8,)
      assert ids_t.shape == (8,)
      # Check that we have 4 positives and 4 negatives
      assert np.sum(y_t == 0) == 4
      assert np.sum(y_t == 1) == 4
      # Check that sum of 0s equals sum of 1s in transformed for each task
      assert np.isclose(np.sum(w_t[y_t == 0]), np.sum(w_t[y_t == 1]))
  
file_path: deepchem/deepchem/trans/tests/test_duplicate_balancing.py
imports: import numpy
  import tempfile
  import deepchem
label_desc: Use image node_id 1 for calling a global function with example usage: test_binary_1d() without return types