<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 The textwrap module can be used to format text for output in situations where pretty-printing is desired. It offers programmatic functionality similar to the paragraph wrapping or filling features found in many text editors and word processors.
Step1:  Structure of this module
There are 2 way of invoking this module
textwrap.TextWrapper(**kwargs)
this module also provide some convinient function 
Let's start with convinient functiones.
Step2:  Convinient functiones
textwrap.wrap(text, width=70, **kwargs)
Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines
Step3:  textwrap.fill(text, width=70, **kwargs)
Wraps the single paragraph in text, and returns a single string containing the wrapped paragraph
Step4:  textwrap.dedent(text)
Remove any common leading whitespace from every line in text.
Step5:  you probaly notice that the result of textwrap.fill have some unwanted space. in this case we can work around this by dedent it first then fill.
Step6:  textwrap.indent(text, prefix, predicate=None)
Add prefix to the beginning of selected lines in text.
Step7:  To control which lines receive the new prefix, pass a callable as the predicate argument to indent(). The callable will be invoked for each line of text in turn and the prefix will be added for lines where the return value is true.
Step8:  This example adds the prefix EVEN to lines that contain an even number of characters.
textwrap.shorten(text, width, **kwargs)
Collapse and truncate the given text to fit in the given width.
First the whitespace in text is collapsed (all whitespace is replaced by single spaces). If the result fits in the width, it is returned. Otherwise, enough words are dropped from the end so that the remaining words plus the placeholder fit within width
Step9:  textwrap.TextWrapper(**kwargs)
If you want more convinient or efficient solution. you should use TextWrapper directly.
you may notice that 
textwrap.wrap(text, width=70, **kwargs)
textwrap.fill(text, width=70, **kwargs)
textwrap.shorten(text, width=70, **kwargs)
have optional kwargs arguments. These optional arguments correspond to the instance attributes of TextWrapper.
for complete list, refer to official doc
Example
<ASSISTANT_TASK:>
Python Code:
import textwrap
Explanation: The textwrap module can be used to format text for output in situations where pretty-printing is desired. It offers programmatic functionality similar to the paragraph wrapping or filling features found in many text editors and word processors.
End of explanation
sample_text = '''
    The textwrap module can be used to format text for output in
    situations where pretty-printing is desired.  It offers
    programmatic functionality similar to the paragraph wrapping
    or filling features found in many text editors.
    '''
Explanation: Structure of this module
There are 2 way of invoking this module
textwrap.TextWrapper(**kwargs)
this module also provide some convinient function 
Let's start with convinient functiones.
End of explanation
wrap_result = textwrap.wrap(sample_text,width=30)
wrap_result
Explanation: Convinient functiones
textwrap.wrap(text, width=70, **kwargs)
Wraps the single paragraph in text (a string) so every line is at most width characters long. Returns a list of output lines, without final newlines
End of explanation
fill_result = textwrap.fill(sample_text,width=30)
fill_result
Explanation: textwrap.fill(text, width=70, **kwargs)
Wraps the single paragraph in text, and returns a single string containing the wrapped paragraph
End of explanation
# before dedent
sample_text
dedent_result = textwrap.dedent(sample_text)
# after dedent
dedent_result
Explanation: textwrap.dedent(text)
Remove any common leading whitespace from every line in text.
End of explanation
dedent_result_wrap = textwrap.fill(dedent_result,width=30)
dedent_result_wrap
Explanation: you probaly notice that the result of textwrap.fill have some unwanted space. in this case we can work around this by dedent it first then fill.
End of explanation
indent_result = textwrap.indent(sample_text,prefix="=A=")
indent_result
print(indent_result)
Explanation: textwrap.indent(text, prefix, predicate=None)
Add prefix to the beginning of selected lines in text.
End of explanation
def should_indent(line):
    print('Indent {!r}?'.format(line))
    return len(line.strip()) % 2 == 0
dedented_text = textwrap.dedent(sample_text)
wrapped = textwrap.fill(dedented_text, width=50)
final = textwrap.indent(wrapped, 'EVEN ',
                        predicate=should_indent)
print('\nQuoted block:\n')
print(final)
Explanation: To control which lines receive the new prefix, pass a callable as the predicate argument to indent(). The callable will be invoked for each line of text in turn and the prefix will be added for lines where the return value is true.
End of explanation
shorten_result = textwrap.shorten(sample_text,width=90)
shorten_result
# use different placeholder
shorten_result_1 = textwrap.shorten(sample_text,width=90,placeholder='....')
shorten_result_1
Explanation: This example adds the prefix EVEN to lines that contain an even number of characters.
textwrap.shorten(text, width, **kwargs)
Collapse and truncate the given text to fit in the given width.
First the whitespace in text is collapsed (all whitespace is replaced by single spaces). If the result fits in the width, it is returned. Otherwise, enough words are dropped from the end so that the remaining words plus the placeholder fit within width
End of explanation
dedented_text = textwrap.dedent(sample_text).strip()
print(textwrap.fill(dedented_text,
                    initial_indent='',
                    subsequent_indent=' ' * 4,
                    width=50,
                    ))
Explanation: textwrap.TextWrapper(**kwargs)
If you want more convinient or efficient solution. you should use TextWrapper directly.
you may notice that 
textwrap.wrap(text, width=70, **kwargs)
textwrap.fill(text, width=70, **kwargs)
textwrap.shorten(text, width=70, **kwargs)
have optional kwargs arguments. These optional arguments correspond to the instance attributes of TextWrapper.
for complete list, refer to official doc
Example:
it is possible to set the width of the output, the indent of the first line can be controlled independently of subsequent lines.
End of explanation
<END_TASK>