code: def dim(self, layer_to_dim):
      if self.operator is None:
          # base-case: self.items = [ layer_name ] (or sub-layer name, like
          # 'lstm.memory_cell').
          return layer_to_dim(self.items[0])
      elif self.operator in ["Sum", "Failover", "IfDefined", "Switch"]:
          # these are all operators for which all args are descriptors
          # and must have the same dim.
          dim = self.items[0].dim(layer_to_dim)
          for desc in self.items[1:]:
              next_dim = desc.dim(layer_to_dim)
              if next_dim != dim:
                  raise RuntimeError(
                      "In descriptor {0}, different fields have different "
                      "dimensions: {1} != {2}".format(
                          self.str(), dim, next_dim
                      )
                  )
          return dim
      elif self.operator in ["Offset", "Round", "ReplaceIndex"]:
          # for these operators, only the 1st arg is relevant.
          return self.items[0].dim(layer_to_dim)
      elif self.operator == "Append":
          return sum([x.dim(layer_to_dim) for x in self.items])
      elif self.operator == "Scale":
          # e.g. Scale(2.0, lstm1).  Return dim of 2nd arg.
          return self.items[1].dim(layer_to_dim)
      elif self.operator == "Const":
          # e.g. Const(0.5, 512).  Return 2nd arg, which is an int.
          return self.items[1]
      else:
          raise RuntimeError(
              "Unknown operator {0}".format(self.operator)
          )
  
imports: from __future__ import print_function
  from __future__ import division
  import re
  import sys
label_desc: Use image node_id 5 for calling the Descriptor obj's underlying member method code with example usage: obj.dim(layer_to_dim) and returns: layer_to_dim, dim, self, sum, self, self