# Buggy code
def __call__(self, a, bins, range, weights):
    if range is not None:
        _check_range(range)
    if isinstance(bins, str):
        # string, 'auto', 'stone', ...
        # shape is unknown
        bin_name = bins
        # if `bins` is a string for an automatic method,
        # this will replace it with the number of bins calculated
        if bin_name not in _hist_bin_selectors:
            raise ValueError(f"{bin_name!r} is not a valid estimator for `bins`")
        if weights is not None:
            raise TypeError(
                "Automated estimation of the number of "
                "bins is not supported for weighted data"
            )
        if isinstance(range, tuple) and len(range) == 2:
            # if `bins` is a string, e.g. 'auto', 'stone'...,
            # and `range` provided as well,
            # `a` should be trimmed first
            first_edge, last_edge = _get_outer_edges(a, range)
            a = a[(a >= first_edge) & (a <= last_edge)]
        shape = (np.nan,)
    elif mt.ndim(bins) == 0:
        try:
            n_equal_bins = operator.index(bins)
        except TypeError:  # pragma: no cover
            raise TypeError("`bins` must be an integer, a string, or an array")
        if n_equal_bins < 1:
            raise ValueError("`bins` must be positive, when an integer")
        shape = (bins + 1,)
    elif mt.ndim(bins) == 1:
        if not isinstance(bins, TENSOR_TYPE):
            bins = np.asarray(bins)
            if not is_asc_sorted(bins):
                raise ValueError("`bins` must increase monotonically, when an array")
        shape = astensor(bins).shape
    else:
        raise ValueError("`bins` must be 1d, when an array")

    inputs = [a]
    if isinstance(bins, TENSOR_TYPE):
        inputs.append(bins)
    if weights is not None:
        inputs.append(weights)
    if (
        (a.size > 0 or np.isnan(a.size))
        and (isinstance(bins, str) or mt.ndim(bins) == 0)
        and not range
    ):
        # for bins that is str or integer,
        # requires min max calculated first
        input_min = self._input_min = a.min()
        inputs.append(input_min)
        input_max = self._input_max = a.max()
        inputs.append(input_max)

    return self.new_tensor(inputs, shape=shape, order=TensorOrder.C_ORDER)


# Traceback (TypeError)
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 479, in send
r = low_conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 482, in send
r = low_conn.getresponse()
File "/opt/conda/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/opt/conda/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/opt/conda/lib/python3.7/http/client.py", line 267, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/conda/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/gevent/threadpool.py", line 142, in __run_task
thread_result.set(func(*args, **kwargs))
File "mars/actors/pool/gevent_pool.pyx", line 201, in mars.actors.pool.gevent_pool.GeventThreadPool._wrap_watch.inner
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 698, in execute_graph
res = graph_execution.execute(retval)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 579, in execute
future.result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 435, in result
return self.__get_result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/opt/conda/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 446, in _execute_operand
self.handle_op(first_op, results, self._mock)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 378, in handle_op
return Executor.handle(*args, **kw)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 649, in handle
return runner(results, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 359, in execute
cls._execute_arrow_tunnel(ctx, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 349, in _execute_arrow_tunnel
writer.close()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 548, in close
self._flush()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 545, in _flush
self._request_callback(gen())
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/tabletunnel.py", line 315, in upload
self._client.put(url, data=data, params=params, headers=headers)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 154, in put
return self.request(url, 'put', data=data, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 133, in request
proxies=self._proxy)
File "/opt/conda/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: timed out
2021-02-03T05:21:04Z (<ThreadPoolWorker at 0x7f14c2e8e7e0 thread_ident=0x7f14cfe3f700 threadpool-hub=<Hub at 0x7f14c338d1d0 thread_ident=0x7f14f8070740>>, <cyfunction GeventThreadPool._wrap_watch.<locals>.inner at 0x7f14c2ec37a0>) failed with ConnectionError

2021-02-03 13:21:04,748 mars.worker.calc 77 ERROR    Unexpected exception occurred in BaseCalcActor._calc_results. graph_key=402439ba636c37f11bea13fe28ad9bfb
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 479, in send
r = low_conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 482, in send
r = low_conn.getresponse()
File "/opt/conda/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/opt/conda/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/opt/conda/lib/python3.7/http/client.py", line 267, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/conda/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 200, in _calc_results
chunk_targets, retval=False).result()
File "src/gevent/event.py", line 383, in gevent._gevent_cevent.AsyncResult.result
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/opt/conda/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/opt/conda/lib/python3.7/site-packages/gevent/threadpool.py", line 142, in __run_task
thread_result.set(func(*args, **kwargs))
File "mars/actors/pool/gevent_pool.pyx", line 201, in mars.actors.pool.gevent_pool.GeventThreadPool._wrap_watch.inner
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 698, in execute_graph
res = graph_execution.execute(retval)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 579, in execute
future.result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 435, in result
return self.__get_result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/opt/conda/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 446, in _execute_operand
self.handle_op(first_op, results, self._mock)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 378, in handle_op
return Executor.handle(*args, **kw)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 649, in handle
return runner(results, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 359, in execute
cls._execute_arrow_tunnel(ctx, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 349, in _execute_arrow_tunnel
writer.close()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 548, in close
self._flush()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 545, in _flush
self._request_callback(gen())
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/tabletunnel.py", line 315, in upload
self._client.put(url, data=data, params=params, headers=headers)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 154, in put
return self.request(url, 'put', data=data, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 133, in request
proxies=self._proxy)
File "/opt/conda/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: timed out
2021-02-03 13:21:04,749 mars.promise 77 ERROR    Exception met in executing promise.
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 479, in send
r = low_conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 482, in send
r = low_conn.getresponse()
File "/opt/conda/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/opt/conda/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/opt/conda/lib/python3.7/http/client.py", line 267, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/conda/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/mars/promise.py", line 100, in _wrapped
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 301, in <lambda>
.then(lambda context_dict: _start_calc(context_dict)) \
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 276, in _start_calc
return self._calc_results(session_id, graph_key, graph, context_dict, chunk_targets)
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 200, in _calc_results
chunk_targets, retval=False).result()
File "src/gevent/event.py", line 383, in gevent._gevent_cevent.AsyncResult.result
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/opt/conda/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/opt/conda/lib/python3.7/site-packages/gevent/threadpool.py", line 142, in __run_task
thread_result.set(func(*args, **kwargs))
File "mars/actors/pool/gevent_pool.pyx", line 201, in mars.actors.pool.gevent_pool.GeventThreadPool._wrap_watch.inner
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 698, in execute_graph
res = graph_execution.execute(retval)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 579, in execute
future.result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 435, in result
return self.__get_result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/opt/conda/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 446, in _execute_operand
self.handle_op(first_op, results, self._mock)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 378, in handle_op
return Executor.handle(*args, **kw)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 649, in handle
return runner(results, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 359, in execute
cls._execute_arrow_tunnel(ctx, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 349, in _execute_arrow_tunnel
writer.close()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 548, in close
self._flush()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 545, in _flush
self._request_callback(gen())
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/tabletunnel.py", line 315, in upload
self._client.put(url, data=data, params=params, headers=headers)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 154, in put
return self.request(url, 'put', data=data, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 133, in request
proxies=self._proxy)
File "/opt/conda/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: timed out
2021-02-03 13:21:04,751 mars.promise 77 ERROR    Unhandled exception in promise
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 479, in send
r = low_conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 482, in send
r = low_conn.getresponse()
File "/opt/conda/lib/python3.7/http/client.py", line 1344, in getresponse
response.begin()
File "/opt/conda/lib/python3.7/http/client.py", line 306, in begin
version, status, reason = self._read_status()
File "/opt/conda/lib/python3.7/http/client.py", line 267, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/conda/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/mars/promise.py", line 100, in _wrapped
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 301, in <lambda>
.then(lambda context_dict: _start_calc(context_dict)) \
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 276, in _start_calc
return self._calc_results(session_id, graph_key, graph, context_dict, chunk_targets)
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 383, in _wrapped
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 200, in _calc_results
chunk_targets, retval=False).result()
File "src/gevent/event.py", line 383, in gevent._gevent_cevent.AsyncResult.result
File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/opt/conda/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/opt/conda/lib/python3.7/site-packages/gevent/threadpool.py", line 142, in __run_task
thread_result.set(func(*args, **kwargs))
File "mars/actors/pool/gevent_pool.pyx", line 201, in mars.actors.pool.gevent_pool.GeventThreadPool._wrap_watch.inner
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 698, in execute_graph
res = graph_execution.execute(retval)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 579, in execute
future.result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 435, in result
return self.__get_result()
File "/opt/conda/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/opt/conda/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/utils.py", line 457, in _inner
return func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 446, in _execute_operand
self.handle_op(first_op, results, self._mock)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 378, in handle_op
return Executor.handle(*args, **kw)
File "/opt/conda/lib/python3.7/site-packages/mars/executor.py", line 649, in handle
return runner(results, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 359, in execute
cls._execute_arrow_tunnel(ctx, op)
File "/opt/conda/lib/python3.7/site-packages/odps/mars_extension/dataframe/datastore.py", line 349, in _execute_arrow_tunnel
writer.close()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 548, in close
self._flush()
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/io/writer.py", line 545, in _flush
self._request_callback(gen())
File "/opt/conda/lib/python3.7/site-packages/odps/tunnel/tabletunnel.py", line 315, in upload
self._client.put(url, data=data, params=params, headers=headers)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 154, in put
return self.request(url, 'put', data=data, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/odps/rest.py", line 133, in request
proxies=self._proxy)
File "/opt/conda/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: timed out
2021-02-03 13:21:04,753 mars.promise 77 ERROR    Exception met in executing promise.
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/mars/promise.py", line 100, in _wrapped
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 302, in <lambda>
.then(lambda keys: _finalize(keys, None), lambda *exc_info: _finalize(None, exc_info))
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 285, in _finalize
self.tell_promise(callback, *exc_info, _accept=False)
File "/opt/conda/lib/python3.7/site-packages/mars/promise.py", line 530, in tell_promise
return self.ctx.actor_ref(uid, address=address).tell(callback_args, wait=wait)
File "mars/actors/core.pyx", line 39, in mars.actors.core.ActorRef.tell
File "mars/actors/core.pyx", line 41, in mars.actors.core.ActorRef.tell
File "mars/actors/pool/gevent_pool.pyx", line 282, in mars.actors.pool.gevent_pool.ActorContext.tell
File "mars/actors/pool/gevent_pool.pyx", line 853, in mars.actors.pool.gevent_pool.Communicator.tell
File "mars/actors/pool/gevent_pool.pyx", line 859, in mars.actors.pool.gevent_pool.Communicator.tell
File "mars/actors/pool/gevent_pool.pyx", line 846, in mars.actors.pool.gevent_pool.Communicator._send
File "mars/actors/pool/gevent_pool.pyx", line 755, in mars.actors.pool.gevent_pool.Communicator._dispatch
File "mars/actors/pool/gevent_pool.pyx", line 819, in mars.actors.pool.gevent_pool.Communicator._send_process
File "mars/actors/pool/messages.pyx", line 570, in mars.actors.pool.messages.pack_tell_message
File "mars/actors/pool/messages.pyx", line 526, in mars.actors.pool.messages._pack_send_message
File "mars/actors/pool/messages.pyx", line 469, in mars.actors.pool.messages._pack_message
File "mars/actors/pool/messages.pyx", line 436, in mars.actors.pool.messages._pack_tuple_message
TypeError: can't pickle generator objects
2021-02-03 13:21:04,754 mars.promise 77 ERROR    Unhandled exception in promise
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/mars/promise.py", line 100, in _wrapped
result = func(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 302, in <lambda>
.then(lambda keys: _finalize(keys, None), lambda *exc_info: _finalize(None, exc_info))
File "/opt/conda/lib/python3.7/site-packages/mars/worker/calc.py", line 285, in _finalize
self.tell_promise(callback, *exc_info, _accept=False)
File "/opt/conda/lib/python3.7/site-packages/mars/promise.py", line 530, in tell_promise
return self.ctx.actor_ref(uid, address=address).tell(callback_args, wait=wait)
File "mars/actors/core.pyx", line 39, in mars.actors.core.ActorRef.tell
File "mars/actors/core.pyx", line 41, in mars.actors.core.ActorRef.tell
File "mars/actors/pool/gevent_pool.pyx", line 282, in mars.actors.pool.gevent_pool.ActorContext.tell
File "mars/actors/pool/gevent_pool.pyx", line 853, in mars.actors.pool.gevent_pool.Communicator.tell
File "mars/actors/pool/gevent_pool.pyx", line 859, in mars.actors.pool.gevent_pool.Communicator.tell
File "mars/actors/pool/gevent_pool.pyx", line 846, in mars.actors.pool.gevent_pool.Communicator._send
File "mars/actors/pool/gevent_pool.pyx", line 755, in mars.actors.pool.gevent_pool.Communicator._dispatch
File "mars/actors/pool/gevent_pool.pyx", line 819, in mars.actors.pool.gevent_pool.Communicator._send_process
2021-02-03 13:21:02,172 mars.worker.execution 58 DEBUG    Executing states: {'402439ba636c37f11bea13fe28ad9bfb': (278.46709537506104, 'CALCULATING'), '4a57865de1482157ed1f3bdd28b8d030': (75.9635705947876, 'CALCULATING')}
File "mars/actors/pool/messages.pyx", line 570, in mars.actors.pool.messages.pack_tell_message
File "mars/actors/pool/messages.pyx", line 526, in mars.actors.pool.messages._pack_send_message
File "mars/actors/pool/messages.pyx", line 469, in mars.actors.pool.messages._pack_message
File "mars/actors/pool/messages.pyx", line 436, in mars.actors.pool.messages._pack_tuple_message
TypeError: can't pickle generator objects

# Fixed code
def __call__(self, a, bins, range, weights):
    if range is not None:
        _check_range(range)
    if isinstance(bins, str):
        # string, 'auto', 'stone', ...
        # shape is unknown
        bin_name = bins
        # if `bins` is a string for an automatic method,
        # this will replace it with the number of bins calculated
        if bin_name not in _hist_bin_selectors:
            raise ValueError(f"{bin_name!r} is not a valid estimator for `bins`")
        if weights is not None:
            raise TypeError(
                "Automated estimation of the number of "
                "bins is not supported for weighted data"
            )
        if isinstance(range, tuple) and len(range) == 2:
            # if `bins` is a string, e.g. 'auto', 'stone'...,
            # and `range` provided as well,
            # `a` should be trimmed first
            first_edge, last_edge = _get_outer_edges(a, range)
            a = a[(a >= first_edge) & (a <= last_edge)]
        shape = (np.nan,)
    elif mt.ndim(bins) == 0:
        try:
            n_equal_bins = operator.index(bins)
        except TypeError:  # pragma: no cover
            raise TypeError("`bins` must be an integer, a string, or an array")
        if n_equal_bins < 1:
            raise ValueError("`bins` must be positive, when an integer")
        shape = (bins + 1,)
    elif mt.ndim(bins) == 1:
        if not isinstance(bins, TENSOR_TYPE):
            bins = np.asarray(bins)
            if not is_asc_sorted(bins):
                raise ValueError("`bins` must increase monotonically, when an array")
        shape = astensor(bins).shape
    else:
        raise ValueError("`bins` must be 1d, when an array")

    inputs = [a]
    if isinstance(bins, TENSOR_TYPE):
        inputs.append(bins)
    if weights is not None:
        inputs.append(weights)
    if (
        (a.size > 0 or np.isnan(a.size))
        and (isinstance(bins, str) or mt.ndim(bins) == 0)
        and not range
    ):
        # for bins that is str or integer, requires min max calculated first
        # dims need to be kept in case a is empty which causes errors in reduction
        input_min = self._input_min = a.min(keepdims=True)
        inputs.append(input_min)
        input_max = self._input_max = a.max(keepdims=True)
        inputs.append(input_max)

    return self.new_tensor(inputs, shape=shape, order=TensorOrder.C_ORDER)