<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __EncodedAttribute_encode_jpeg_gray8(self, gray8, width=0, height=0, quality=100.0):
 """Encode a 8 bit grayscale image as JPEG format :param gray8: an object containning image information :type gray8: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> > :param width: image width. **MUST** be given if gray8 is a string or if it is a :class:`numpy.ndarray` with ndims != 2. Otherwise it is calculated internally. :type width: :py:obj:`int` :param height: image height. **MUST** be given if gray8 is a string or if it is a :class:`numpy.ndarray` with ndims != 2. Otherwise it is calculated internally. :type height: :py:obj:`int` :param quality: Quality of JPEG (0=poor quality 100=max quality) (default is 100.0) :type quality: :py:obj:`float` .. note:: When :class:`numpy.ndarray` is given: - gray8 **MUST** be CONTIGUOUS, ALIGNED - if gray8.ndims != 2, width and height **MUST** be given and gray8.nbytes **MUST** match width*height - if gray8.ndims == 2, gray8.itemsize **MUST** be 1 (typically, gray8.dtype is one of `numpy.dtype.byte`, `numpy.dtype.ubyte`, `numpy.dtype.int8` or `numpy.dtype.uint8`) Example:: def read_myattr(self, attr):
 enc = tango.EncodedAttribute() data = numpy.arange(100, dtype=numpy.byte) data = numpy.array((data,data,data)) enc.encode_jpeg_gray8(data) attr.set_value(enc) """

    self._generic_encode_gray8(gray8, width=width, height=height, quality=quality, format=_ImageFormat.JpegImage)