code: def transfer(model, sess, weightmap, task):
      for key, (layer, op) in weightmap.items():
          link = model
  
          try:
              for sublink in key:
                  link = link[sublink]
          except AttributeError:
              continue
  
          print("loading: {}".format("/".join(key)))
  
          input_dict = {}
          transpose = {}
          if layer == "Convolution2D":
              input_dict["W"] = op + "/weights:0"
              input_dict["b"] = op + "/biases:0"
              transpose["W"] = (3, 2, 0, 1)
          elif layer == "Convolution2D_depthwise":
              input_dict["W"] = op + "/depthwise_weights:0"
              transpose["W"] = (2, 3, 0, 1)
          elif layer == "BatchNormalization":
              input_dict["gamma"] = op + "/gamma:0"
              input_dict["beta"] = op + "/beta:0"
              input_dict["avg_mean"] = op + "/moving_mean:0"
              input_dict["avg_var"] = op + "/moving_variance:0"
          else:
              raise ValueError("Invalid layer: {}".format(layer))
  
          for k in list(input_dict.keys()):
              if not hasattr(link, k) or getattr(link, k) is None:
                  input_dict.pop(k)
  
          weights = sess.run(input_dict)
  
          for k in input_dict:
              # eliminate some channels
              if key == _last_layer:
                  mask = [
                      i not in _eliminated_channels[task]
                      for i in range(weights[k].shape[-1])
                  ]
                  if k == "W":
                      weights[k] = weights[k][:, :, :, mask]
                  elif k == "b":
                      weights[k] = weights[k][mask]
              load_param(getattr(link, k), weights[k], transpose.get(k))
  
file_path: chainercv/examples/deeplab/tf2npz.py
imports: import argparse
  import chainer
  from chainercv.datasets import ade20k_semantic_segmentation_label_names
  from chainercv.datasets import cityscapes_semantic_segmentation_label_names
  from chainercv.datasets import voc_semantic_segmentation_label_names
  from chainercv.links import DeepLabV3plusXception65
  import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: transfer(model, sess, weightmap, task) without return types