code: def __init__(self, net=None, device_map=None):
      if net is not None:
          serialized_proto = None
          if isinstance(net, core.Net):
              serialized_proto = net.Proto().SerializeToString()
          elif isinstance(net, caffe2_pb2.NetDef):
              serialized_proto = net.SerializeToString()
  
          # Distributed
          if device_map is not None:
              serialized_device_map = {}
              for k in device_map:
                  serialized_device_map[k] = device_map[
                      k
                  ].SerializeToString()
              self._NNModule = C.NNModuleFromProtobufDistributed(
                  serialized_proto, serialized_device_map
              )
          # Default
          elif serialized_proto:
              self._NNModule, self._OpList = C.NNModuleFromProtobuf(
                  serialized_proto
              )
          else:
              raise Exception(
                  "NNModule can be constructed with core.Net or caffe2_pb2.NetDef types"
              )
      else:
          self._NNModule = C.NNModule()
  
imports: import errno
  import os
  from subprocess import PIPE, Popen
  import caffe2.python._import_c_extension
  from caffe2.proto import caffe2_pb2
  from caffe2.python import core
label_desc: Use image node_id 1 to create a new NNModule object  with example: obj = NNModule(net, device_map)