code: def main():
      opt = parsing_data()
  
      print("[INFO]Reading data")
      # Dictionary with data parameters for NiftyNet Reader
      if torch.cuda.is_available():
          print("[INFO] GPU available.")
          device = torch.device(
              "cuda:0" if torch.cuda.is_available() else "cpu"
          )
  
      else:
          raise Exception(
              "[INFO] No GPU found or Wrong gpu id, please run without --cuda"
          )
  
      # Dictionary with data parameters for NiftyNet Reader
      data_param = {
          "image": {
              "path_to_search": opt.image_path,
              "filename_contains": "CC",
          },
          "label": {
              "path_to_search": opt.label_path,
              "filename_contains": "CC",
          },
      }
  
      image_sets_partitioner = ImageSetsPartitioner().initialise(
          data_param=data_param,
          data_split_file=opt.data_split_file,
          new_partition=False,
          ratios=opt.ratios,
      )
  
      readers = {
          x: get_reader(data_param, image_sets_partitioner, x)
          for x in ["training", "validation", "inference"]
      }
      samplers = {
          x: get_sampler(readers[x], opt.patch_size, x)
          for x in ["training", "validation", "inference"]
      }
  
      # Training stage only
      dsets = {
          x: dset_utils.DatasetNiftySampler(sampler=samplers[x])
          for x in ["training", "validation"]
      }
  
      print("[INFO] Building model")
      model = cnn_utils.UNet3D(opt.in_channels, opt.n_classes)
      criterion = loss_utils.SoftDiceLoss()
      optimizer = optim.RMSprop(model.parameters(), lr=opt.lr)
  
      print("[INFO] Training")
      train(
          dsets,
          model,
          criterion,
          optimizer,
          opt.num_epochs,
          device,
          opt.cp_path,
          opt.batch_size,
      )
  
      print("[INFO] Inference")
      inference(
          samplers["inference"],
          model,
          device,
          opt.pred_path,
          opt.cp_path,
      )
  
imports: import argparse
  import time
  import numpy
  import torch
  import torch.optim
  from libs import dataset_niftynet
  from libs import loss
  from libs import model
  from torch.utils.data import DataLoader
  from niftynet.engine.sampler_grid_v2 import GridSampler
  from niftynet.engine.sampler_uniform_v2 import UniformSampler
  from niftynet.engine.signal import TRAIN, VALID, INFER
  from niftynet.engine.windows_aggregator_grid import GridSamplesAggregator
  from niftynet.evaluation.pairwise_measures import PairwiseMeasures
  from niftynet.io.image_reader import ImageReader
  from niftynet.io.image_sets_partitioner import ImageSetsPartitioner
  from niftynet.layer.mean_variance_normalisation import MeanVarNormalisationLayer
  from niftynet.layer.pad import PadLayer
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types