code: def test_transform_to_directory():
      """Test that output can be written to a directory."""
      n_samples = 10
      n_features = 3
      np.random.seed(123)
      X = np.random.rand(n_samples, n_features)
      # Note class imbalance. This will round to 2x duplication for 1
      y = np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0])
      w = np.ones((n_samples,))
      dataset = dc.data.NumpyDataset(X, y, w)
  
      duplicator = dc.trans.DuplicateBalancingTransformer(
          dataset=dataset
      )
      with tempfile.TemporaryDirectory() as tmpdirname:
          dataset = duplicator.transform(dataset, out_dir=tmpdirname)
          balanced_dataset = dc.data.DiskDataset(tmpdirname)
          X_t, y_t, w_t, ids_t = (
              balanced_dataset.X,
              balanced_dataset.y,
              balanced_dataset.w,
              balanced_dataset.ids,
          )
          # Check that we have length 13 now with duplication
          assert len(balanced_dataset) == 13
      # Check shapes
      assert X_t.shape == (13, n_features)
      assert y_t.shape == (13,)
      assert w_t.shape == (13,)
      assert ids_t.shape == (13,)
      # Check that we have 6 positives and 7 negatives
      assert np.sum(y_t == 0) == 7
      assert np.sum(y_t == 1) == 6
  
file_path: deepchem/deepchem/trans/tests/test_duplicate_balancing.py
imports: import numpy
  import tempfile
  import deepchem
label_desc: Use image node_id 5 for calling a global function with example usage: test_transform_to_directory() without return types