class_docstr: A helper class for handling relay functions from darknet model.
docstr: Parse attributes of each layer and return.
docstr_tok: ["Parse","attributes","of","each","layer","and","return","."]
code: def _get_darknet_attrs(self, layer, layer_num):
      """Parse attributes of each layer and return."""
      attr = {}
      use_flatten = True
      layer_type = LAYERTYPE(layer.type)
      if LAYERTYPE.CONVOLUTIONAL == layer_type:
          attr.update({"pad": layer.pad})
          attr.update({"num_group": layer.groups})
          attr.update({"num_filter": layer.n})
          attr.update({"stride": layer.stride})
          attr.update({"kernel": layer.size})
          attr.update({"activation": (layer.activation)})
  
          if layer.nbiases == 0:
              attr.update({"use_bias": False})
          else:
              attr.update({"use_bias": True})
  
          if layer.batch_normalize == 1 and layer.dontloadscales != 1:
              attr.update({"use_batchNorm": True})
              attr.update({"use_scales": True})
  
      elif LAYERTYPE.CONNECTED == layer_type:
          attr.update({"num_hidden": layer.outputs})
          attr.update({"activation": (layer.activation)})
          if layer_num != 0:
              layer_prev = self._net.layers[layer_num - 1]
              if (
                  layer_prev.out_h == layer.h
                  and layer_prev.out_w == layer.w
                  and layer_prev.out_c == layer.c
              ):
                  use_flatten = False
          attr.update({"use_flatten": use_flatten})
          attr.update({"use_bias": True})
          if layer.batch_normalize == 1 and layer.dontloadscales != 1:
              attr.update({"use_batchNorm": True})
              attr.update({"use_scales": True})
              attr.update({"use_bias": False})
  
      elif LAYERTYPE.MAXPOOL == layer_type:
          attr.update({"pad": layer.pad})
          attr.update({"stride": layer.stride})
          attr.update({"kernel": layer.size})
          max_output = (layer.w - layer.size + 2 * layer.pad) / float(
              layer.stride
          ) + 1
          if max_output < layer.out_w:
              extra_pad = (layer.out_w - max_output) * layer.stride
              attr.update({"extra_pad_size": int(extra_pad)})
      elif LAYERTYPE.AVGPOOL == layer_type:
          attr.update({"pad": layer.pad})
          if layer.stride == 0:
              attr.update({"stride": 1})
          else:
              attr.update({"stride": layer.stride})
          if layer.size == 0 and layer.h == layer.w:
              attr.update({"kernel": layer.h})
          else:
              attr.update({"kernel": layer.size})
  
      elif LAYERTYPE.DROPOUT == layer_type:
          attr.update({"p": layer.probability})
  
      elif LAYERTYPE.SOFTMAX == layer_type:
          attr.update({"axis": 1})
          attr.update({"use_flatten": True})
          if layer.temperature:
              attr.update({"temperature": str(layer.temperature)})
  
      elif LAYERTYPE.SHORTCUT == layer_type:
          add_layer = self._net.layers[layer.index]
          attr.update({"activation": layer.activation})
          attr.update({"out_channel": layer.out_c})
          attr.update({"out_size": layer.out_h})
          attr.update({"add_out_channel": add_layer.out_c})
          attr.update({"add_out_size": add_layer.out_h})
  
      elif LAYERTYPE.ROUTE == layer_type:
          pass
  
      elif LAYERTYPE.COST == layer_type:
          pass
  
      elif LAYERTYPE.REORG == layer_type:
          attr.update({"stride": layer.stride})
  
      elif LAYERTYPE.REGION == layer_type:
          attr.update({"n": layer.n})
          attr.update({"classes": layer.classes})
          attr.update({"coords": layer.coords})
          attr.update({"background": layer.background})
          attr.update({"softmax": layer.softmax})
          attr.update({"shape": (-1, layer.c, layer.h, layer.w)})
  
      elif LAYERTYPE.YOLO == layer_type:
          attr.update({"n": layer.n})
          attr.update({"classes": layer.classes})
          attr.update({"shape": (-1, layer.c, layer.h, layer.w)})
  
      elif LAYERTYPE.UPSAMPLE == layer_type:
          attr.update({"scale": layer.stride})
  
      elif LAYERTYPE.L2NORM == layer_type:
          pass
  
      else:
          err = f"Darknet layer type {layer_type} is not supported in relay."
          raise NotImplementedError(err)
  
      return attr
  
imports: from enum import Enum
  import numpy
  import tvm
  from tvm.ir import IRModule
  from ..None import analysis
  from ..None import expr
  from ..None import function
  from .common import get_relay_op, new_var
label_desc: Use image node_id 8 for calling the GraphProto obj's underlying member method code with example usage: obj._get_darknet_attrs(layer, layer_num) and returns: attr