code: def test_1d_coordinates(self):
      img_size = (32, 1, 1, 1, 1)
      win_size = (15, 1, 1)
      sampling_map = np.zeros(img_size)
      coords = weighted_spatial_coordinates(
          10, img_size, win_size, sampling_map
      )
      self.assertAllEqual(coords.shape, (10, N_SPATIAL))
      self.assertCoordinatesAreValid(coords, sampling_map)
  
      sampling_map[20, 0, 0] = 0.1
      coords = weighted_spatial_coordinates(
          10, img_size, win_size, sampling_map
      )
      self.assertAllEqual(coords.shape, (10, N_SPATIAL))
      self.assertTrue(np.all(coords == [20, 0, 0]))
  
      sampling_map[9, 0, 0] = 0.1
      coords = weighted_spatial_coordinates(
          10, img_size, win_size, sampling_map
      )
      self.assertAllEqual(coords.shape, (10, N_SPATIAL))
      self.assertTrue(
          np.all((coords == [20, 0, 0]) | (coords == [9, 0, 0]))
      )
  
imports: from __future__ import absolute_import, division, print_function
  import os
  import numpy
  import tensorflow
  from niftynet.engine.image_window import N_SPATIAL
  from niftynet.engine.sampler_weighted_v2 import WeightedSampler, weighted_spatial_coordinates
  from niftynet.io.image_reader import ImageReader
  from niftynet.io.image_sets_partitioner import ImageSetsPartitioner
  from niftynet.utilities.util_common import ParserNamespace
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 4 for calling the WeightedCoordinatesTest obj's underlying member method code with example usage: obj.test_1d_coordinates() without return types