parameters: (proto)
docstring: Serialize a in-memory proto to bytes
  
      @params
      proto is a in-memory proto, such as a ModelProto, TensorProto, etc
  
      @return
      Serialized proto in bytes
docstring_summary: Serialize a in-memory proto to bytes
docstring_tokens: Serialize a in - memory proto to bytes
function: def _serialize(proto):  # type: (Union[bytes, google.protobuf.message.Message]) -> bytes
      '''
      Serialize a in-memory proto to bytes
  
      @params
      proto is a in-memory proto, such as a ModelProto, TensorProto, etc
  
      @return
      Serialized proto in bytes
      '''
      if isinstance(proto, bytes):
          return proto
      elif hasattr(proto, 'SerializeToString') and callable(proto.SerializeToString):
          result = proto.SerializeToString()
          return result
      else:
          raise ValueError('No SerializeToString method is detected. '
                           'neither proto is a str.\ntype is {}'.format(type(proto)))
function_tokens: def _serialize ( proto ) : # type: (Union[bytes, google.protobuf.message.Message]) -> bytes if isinstance ( proto , bytes ) : return proto elif hasattr ( proto , 'SerializeToString' ) and callable ( proto . SerializeToString ) : result = proto . SerializeToString ( ) return result else : raise ValueError ( 'No SerializeToString method is detected. ' 'neither proto is a str.\ntype is {}' . format ( type ( proto ) ) )