class_docstr: Serialize a NumPy array for an inference request.
class_docstr_tok: ["Serialize","a","NumPy","array","for","an","inference","request","."]
docstr: Serialize a NumPy array into a buffer containing RecordIO records.
  
  Args:
      data (numpy.ndarray): The data to serialize.
  
  Returns:
      io.BytesIO: A buffer containing the data serialized as records.
docstr_tok: ["Serialize","a","NumPy","array","into","a","buffer","containing","RecordIO","records",".","Args",":","data","(","numpy.ndarray",")",":","The","data","to","serialize",".","Returns",":","io.BytesIO",":","A","buffer","containing","the","data","serialized","as","records","."]
code: def serialize(self, data):
      """Serialize a NumPy array into a buffer containing RecordIO records.
  
      Args:
          data (numpy.ndarray): The data to serialize.
  
      Returns:
          io.BytesIO: A buffer containing the data serialized as records.
      """
      if len(data.shape) == 1:
          data = data.reshape(1, data.shape[0])
  
      if len(data.shape) != 2:
          raise ValueError(
              "Expected a 1D or 2D array, but got a %dD array instead."
              % len(data.shape)
          )
  
      buffer = io.BytesIO()
      write_numpy_to_dense_tensor(buffer, data)
      buffer.seek(0)
  
      return buffer
  
imports: from __future__ import absolute_import
  import io
  import logging
  import struct
  import sys
  import numpy
  from sagemaker.amazon.record_pb2 import Record
  from sagemaker.deprecations import deprecated_class
  from sagemaker.deserializers import SimpleBaseDeserializer
  from sagemaker.serializers import SimpleBaseSerializer
  from sagemaker.utils import DeferredError
label_desc: Use image node_id 2 for calling the RecordSerializer obj's underlying member method code with example usage: obj.serialize(data) and returns: buffer