parameters: (array, encoding='utf8')
return_statement: return np.char.encode(array, encoding)
docstring: Convert NumPy array of `str` to array of `bytes` by encoding each element based on charset `encoding`.
  
      Args:
          array (numpy.ndarray): Array of `str` type representing strings.
          encoding (str): Indicating the charset for encoding (default='utf8').
  
      Returns:
          numpy.ndarray, NumPy array of `bytes`.
docstring_summary: Convert NumPy array of `str` to array of `bytes` by encoding each element based on charset `encoding`.
docstring_tokens: Convert NumPy array of str to array of bytes by encoding each element based on charset encoding .
function: def to_bytes(array, encoding='utf8'):
      """
      Convert NumPy array of `str` to array of `bytes` by encoding each element based on charset `encoding`.
  
      Args:
          array (numpy.ndarray): Array of `str` type representing strings.
          encoding (str): Indicating the charset for encoding (default='utf8').
  
      Returns:
          numpy.ndarray, NumPy array of `bytes`.
      """
  
      if not isinstance(array, np.ndarray):
          raise ValueError('input should be a NumPy array.')
  
      return np.char.encode(array, encoding)
function_tokens: def to_bytes ( array , encoding = 'utf8' ) : if not isinstance ( array , np . ndarray ) : raise ValueError ( 'input should be a NumPy array.' ) return np . char . encode ( array , encoding )