in src/sagemaker_inference/encoder.py [0:0]
def encode(array_like, content_type):
"""Encode an array-like object in a specific content_type to a numpy array.
To understand better what an array-like object is see:
https://docs.scipy.org/doc/numpy/user/basics.creation.html#converting-python-array-like-objects-to-numpy-arrays
Args:
array_like (np.array or Iterable or int or float): to be converted to numpy.
content_type (str): content type to be used.
Returns:
(np.array): object converted as numpy array.
"""
try:
encoder = _encoder_map[content_type]
return encoder(array_like)
except KeyError:
raise errors.UnsupportedFormatError(content_type)