code: def create_resnet_network(network_name, fp16):
      # Input variables denoting the features and label data
      input_var = C.input_variable(
          (num_channels, image_height, image_width)
      )
      label_var = C.input_variable((num_classes))
  
      dtype = np.float16 if fp16 else np.float32
      if fp16:
          graph_input = C.cast(input_var, dtype=np.float16)
          graph_label = C.cast(label_var, dtype=np.float16)
      else:
          graph_input = input_var
          graph_label = label_var
  
      with C.default_options(dtype=dtype):
          stride1x1 = (1, 1)
          stride3x3 = (2, 2)
  
          # create model, and configure learning parameters
          if network_name == "resnet18":
              z = create_imagenet_model_basic(
                  graph_input, [2, 1, 1, 2], num_classes
              )
          elif network_name == "resnet34":
              z = create_imagenet_model_basic(
                  graph_input, [3, 3, 5, 2], num_classes
              )
          elif network_name == "resnet50":
              z = create_imagenet_model_bottleneck(
                  graph_input,
                  [2, 3, 5, 2],
                  num_classes,
                  stride1x1,
                  stride3x3,
              )
          elif network_name == "resnet101":
              z = create_imagenet_model_bottleneck(
                  graph_input,
                  [2, 3, 22, 2],
                  num_classes,
                  stride1x1,
                  stride3x3,
              )
          elif network_name == "resnet152":
              z = create_imagenet_model_bottleneck(
                  graph_input,
                  [2, 7, 35, 2],
                  num_classes,
                  stride1x1,
                  stride3x3,
              )
          else:
              return RuntimeError("Unknown model name!")
  
          # loss and metric
          ce = cross_entropy_with_softmax(z, graph_label)
          errs = classification_error(z, graph_label, topN=1)
          top5Errs = classification_error(z, graph_label, topN=5)
  
      if fp16:
          ce = C.cast(ce, dtype=np.float32)
          errs = C.cast(errs, dtype=np.float32)
          top5Errs = C.cast(top5Errs, dtype=np.float32)
  
      return {
          "name": network_name,
          "feature": input_var,
          "label": label_var,
          "ce": ce,
          "errs": errs,
          "top5Errs": top5Errs,
          "output": z,
      }
  
file_path: CNTK/Examples/Image/Classification/ResNet/Python/TrainResNet_ImageNet_Distributed.py
imports: from __future__ import print_function
  import os
  import argparse
  import cntk
  import numpy
  from cntk import input, cross_entropy_with_softmax, classification_error, Trainer, cntk_py
  from cntk import data_parallel_distributed_learner, block_momentum_distributed_learner, Communicator
  from cntk.learners import nesterov, learning_rate_schedule, momentum_schedule, UnitType
  from cntk.device import try_set_default_device, gpu
  from cntk.train.training_session import *
  from cntk.debugging import *
  from cntk.logging import *
  from resnet_models import *
  import cntk.io.transforms
label_desc: Use image node_id 2 for calling a global function with example usage: create_resnet_network(network_name, fp16) and returns: dict, RuntimeError