code: def param_to_dict(input_data_param):
      """
      Validate the user input ``input_data_param``
      raise an error if it's invalid.
  
      :param input_data_param:
      :return: input data specifications as a nested dictionary
      """
      error_msg = (
          "Unknown ``data_param`` type. "
          "It should be a nested dictionary: "
          '{"modality_name": {"input_property": value}} '
          'or a dictionary of: {"modality_name": '
          "niftynet.utilities.util_common.ParserNamespace}"
      )
      data_param = deepcopy(input_data_param)
      if isinstance(data_param, (ParserNamespace, argparse.Namespace)):
          data_param = vars(data_param)
      if not isinstance(data_param, dict):
          raise ValueError(error_msg)
      for mod in data_param:
          mod_param = data_param[mod]
          if isinstance(
              mod_param, (ParserNamespace, argparse.Namespace)
          ):
              dict_param = vars(mod_param)
          elif isinstance(mod_param, dict):
              dict_param = mod_param
          else:
              raise ValueError(error_msg)
          for data_key in dict_param:
              look_up_operations(data_key, SUPPORTED_DATA_SPEC)
          data_param[mod] = dict_param
      return data_param
  
imports: from __future__ import absolute_import, division, print_function
  from copy import deepcopy
  import argparse
  import numpy
  import pandas
  import tensorflow
  from six import string_types
  from niftynet.io.misc_io import dtype_casting
  from niftynet.io.image_sets_partitioner import COLUMN_UNIQ_ID
  from niftynet.io.image_type import ImageFactory
  from niftynet.layer.base_layer import Layer, DataDependentLayer, RandomisedLayer
  from niftynet.utilities.user_parameters_helper import make_input_tuple
  from niftynet.utilities.util_common import print_progress_bar, ParserNamespace
  from niftynet.io.image_sets_partitioner import ImageSetsPartitioner
  from niftynet.utilities.util_common import look_up_operations
label_desc: Use image node_id 4 for calling a global function with example usage: param_to_dict(input_data_param) and returns: data_param