<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def str_repeat(arr, repeats):
 """ Duplicate each string in the Series or Index. Parameters repeats : int or sequence of int Same value for all (int) or different value per (sequence). Returns ------- Series or Index of object Series or Index of repeated string objects specified by input parameter repeats. Examples -------- 0 a 1 b 2 c dtype: object Single int repeats string in Series 0 aa 1 bb 2 cc dtype: object Sequence of int repeats corresponding string in Series 0 a 1 bb 2 ccc dtype: object """

    if is_scalar(repeats):
        def scalar_rep(x):
            try:
                return bytes.__mul__(x, repeats)
            except TypeError:
                return str.__mul__(x, repeats)

        return _na_map(scalar_rep, arr)
    else:

        def rep(x, r):
            try:
                return bytes.__mul__(x, r)
            except TypeError:
                return str.__mul__(x, r)

        repeats = np.asarray(repeats, dtype=object)
        result = libops.vec_binop(com.values_from_object(arr), repeats, rep)
        return result