<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 xbatch and batch
Step1:  peek
Step2:  bracket
Step3:  <pre>
          1    1    2    2    3    3    4    4    5    5    6    6    7    7    8    8    9
0----5----0----5----0----5----0----5----0----5----0----5----0----5----0----5----0----5----0
   [0   [1   [2   [3   [4   [5   [6   [7   [8   [9   [10  [11  [12  [13  [14  [15  [16  [17
   ]0   ]1   ]2   ]3   ]4   ]5   ]6   ]7   ]8   ]9   ]10  ]11  ]12  ]13  ]14  ]15  ]16  ]17
        ^  ^^^^            ^ ^       ^           ^^^                           ^     ^
        |  ||||            | |       |           |||                           |     |
</pre>
<ASSISTANT_TASK:>
Python Code:
for x in utils.xbatch(2, range(10)):
    print(x)
for x in utils.xbatch(3, ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                          'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']):
    print(x)
for x in utils.xbatch(3, ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                          'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')):
    print(x)
for x in utils.xbatch(2, np.array(range(10))):
    print(x)
utils.xbatch(2, range(10))
utils.batch(2, range(10))
utils.batch(3, [429, 5, 2, 14, 42, 132, 1, 1])
utils.batch(4, range(10))
Explanation: xbatch and batch
End of explanation
it = utils.xbatch(2, range(10))
first_three, new_it = utils.peek(it, 3)
print('First three:', first_three)
print('Iterating through new_it:')
for x in new_it:
    print(x)
print('Iterating through it:')
for x in it:
    print(x)
it = utils.xbatch(2, range(10))
first_three, new_it = utils.peek(it, 3)
print('First three:', first_three)
print('Iterating through it:')
for x in it:
    print(x)
Explanation: peek
End of explanation
data = [8, 11, 12, 13, 14, 27, 29, 37, 49, 50, 51, 79, 85]
Explanation: bracket
End of explanation
utils.bracket(data, 3, 5)
utils.bracket(data, 3, 5, intervals_right_closed=True)
utils.bracket(data, 3, 5, coalesce=True)
utils.bracket(data, 3, 5, intervals_right_closed=True, coalesce=True)
data = [dt.date(2017, 1, 31) + dt.timedelta(days=x) for x in [8, 11, 12, 13, 14, 27, 29, 37, 49, 50, 51, 79, 85]];
data
utils.bracket(data, dt.date(2017, 2, 3), dt.timedelta(days=5))
utils.bracket(data, dt.date(2017, 2, 3), dt.timedelta(days=5), intervals_right_closed=True)
utils.bracket(data, dt.date(2017, 2, 3), dt.timedelta(days=5), coalesce=True)
utils.bracket(data, dt.date(2017, 2, 3), dt.timedelta(days=5), intervals_right_closed=True, coalesce=True)
data = [dt.datetime(2017, 1, 31, 0, 0, 0) + dt.timedelta(minutes=x) for x in [8, 11, 12, 13, 14, 27, 29, 37, 49, 50, 51, 79, 85]];
data
utils.bracket(data, dt.datetime(2017, 1, 31, 0, 3, 0), dt.timedelta(minutes=5))
utils.bracket(data, dt.datetime(2017, 1, 31, 0, 3, 0), dt.timedelta(minutes=5), intervals_right_closed=True)
utils.bracket(data, dt.datetime(2017, 1, 31, 0, 3, 0), dt.timedelta(minutes=5), coalesce=True)
utils.bracket(data, dt.datetime(2017, 1, 31, 0, 3, 0), dt.timedelta(minutes=5), intervals_right_closed=True, coalesce=True)
Explanation: <pre>
          1    1    2    2    3    3    4    4    5    5    6    6    7    7    8    8    9
0----5----0----5----0----5----0----5----0----5----0----5----0----5----0----5----0----5----0
   [0   [1   [2   [3   [4   [5   [6   [7   [8   [9   [10  [11  [12  [13  [14  [15  [16  [17
   ]0   ]1   ]2   ]3   ]4   ]5   ]6   ]7   ]8   ]9   ]10  ]11  ]12  ]13  ]14  ]15  ]16  ]17
        ^  ^^^^            ^ ^       ^           ^^^                           ^     ^
        |  ||||            | |       |           |||                           |     |
</pre>
End of explanation
<END_TASK>