class_docstr: Serialize data in any file by extracting raw bytes from the file.
docstr: Serialize file data to a raw bytes.
  
  Args:
      data (object): Data to be serialized. The data can be a string
          representing file-path or the raw bytes from a file.
  Returns:
      raw-bytes: The data serialized as raw-bytes from the input.
docstr_tok: ["Serialize","file","data","to","a","raw","bytes",".","Args",":","data","(","object",")",":","Data","to","be","serialized",".","The","data","can","be","a","string","representing","file-path","or","the","raw","bytes","from","a","file",".","Returns",":","raw-bytes",":","The","data","serialized","as","raw-bytes","from","the","input","."]
code: def serialize(self, data):
      """Serialize file data to a raw bytes.
  
      Args:
          data (object): Data to be serialized. The data can be a string
              representing file-path or the raw bytes from a file.
      Returns:
          raw-bytes: The data serialized as raw-bytes from the input.
      """
  
      if isinstance(data, str):
          try:
              with open(data, "rb") as data_file:
                  data_file_info = data_file.read()
                  return data_file_info
          except Exception as e:
              raise ValueError(f"Could not open/read file: {data}. {e}")
      if isinstance(data, bytes):
          return data
  
      raise ValueError(
          f"Object of type {type(data)} is not Data serializable."
      )
  
imports: from __future__ import absolute_import
  import abc
  from collections.abc import Iterable
  import csv
  import io
  import json
  import numpy
  from pandas import DataFrame
  from six import with_metaclass
  from sagemaker.utils import DeferredError
label_desc: Use image node_id 2 for calling the DataSerializer obj's underlying member method code with example usage: obj.serialize(data) and returns: data, data_file_info