code: def get_darknet(
      darknet_version,
      num_layers,
      pretrained=False,
      ctx=mx.cpu(),
      root=os.path.join("~", ".mxnet", "models"),
      **kwargs,
  ):
      """Get darknet by `version` and `num_layers` info.
  
      Parameters
      ----------
      darknet_version : str
          Darknet version, choices are ['v3'].
      num_layers : int
          Number of layers.
      pretrained : bool or str
          Boolean value controls whether to load the default pretrained weights for model.
          String value represents the hashtag for a certain version of pretrained weights.
      ctx : Context, default CPU
          The context in which to load the pretrained weights.
      root : str, default '~/.mxnet/models'
          Location for keeping the model parameters.
      norm_layer : object
          Normalization layer used (default: :class:`mxnet.gluon.nn.BatchNorm`)
          Can be :class:`mxnet.gluon.nn.BatchNorm` or :class:`mxnet.gluon.contrib.nn.SyncBatchNorm`.
      norm_kwargs : dict
          Additional `norm_layer` arguments, for example `num_devices=4`
          for :class:`mxnet.gluon.contrib.nn.SyncBatchNorm`.
  
      Returns
      -------
      mxnet.gluon.HybridBlock
          Darknet network.
  
      Examples
      --------
      >>> model = get_darknet('v3', 53, pretrained=True)
      >>> print(model)
  
      """
      assert (
          darknet_version in darknet_versions
          and darknet_version in darknet_spec
      ), "Invalid darknet version: {}. Options are {}".format(
          darknet_version, str(darknet_versions.keys())
      )
      specs = darknet_spec[darknet_version]
      assert (
          num_layers in specs
      ), "Invalid number of layers: {}. Options are {}".format(
          num_layers, str(specs.keys())
      )
      layers, channels = specs[num_layers]
      darknet_class = darknet_versions[darknet_version]
      net = darknet_class(layers, channels, **kwargs)
      if pretrained:
          from ..model_store import get_model_file
  
          net.load_parameters(
              get_model_file(
                  "darknet%d" % (num_layers), tag=pretrained, root=root
              ),
              ctx=ctx,
          )
      return net
  
file_path: gluon-cv/gluoncv/model_zoo/yolo/darknet.py
imports: from __future__ import absolute_import
  import os
  import mxnet
  from mxnet import gluon
  from mxnet.gluon import nn
  from mxnet.gluon.nn import BatchNorm
label_desc: Use image node_id 2 for calling a global function with example usage: get_darknet(darknet_version, num_layers, pretrained, ctx, root) and returns: net