code: def layer_op(self, image, mask=None):
      assert (
          self.is_ready()
      ), "discrete_label_normalisation layer needs to be trained first."
      # mask is not used for label mapping
      if isinstance(image, dict):
          if self.image_name not in image:
              return image, mask
          label_data = np.asarray(image[self.image_name])
      else:
          label_data = np.asarray(image)
  
      mapping_from = self.label_map[self.key[0]]
      mapping_to = self.label_map[self.key[1]]
  
      image_shape = label_data.shape
      label_data = label_data.reshape(-1)
      mapped_data = np.zeros_like(label_data)
      for original, new_id in zip(mapping_from, mapping_to):
          mapped_data[label_data == original] = new_id
      label_data = mapped_data.reshape(image_shape)
  
      if isinstance(image, dict):
          image[self.image_name] = label_data
          return image, mask
      return label_data, mask
  
file_path: NiftyNet/niftynet/layer/discrete_label_normalisation.py
imports: from __future__ import absolute_import, print_function, division
  import os
  import numpy
  import tensorflow
  import niftynet.utilities.histogram_standardisation
  from niftynet.layer.base_layer import DataDependentLayer
  from niftynet.layer.base_layer import Invertible
  from niftynet.utilities.user_parameters_helper import standardise_string
  from niftynet.utilities.util_common import print_progress_bar
label_desc: Use image node_id 4 for calling the DiscreteLabelNormalisationLayer obj's underlying member method code with example usage: obj.layer_op(image, mask) and returns: label_data,  mask, image,  mask, image,  mask