<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">Hello,</p>
<p dir="auto">Trying to subclass:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class MyPool(torch.multiprocessing.Pool):
   pass"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">MyPool</span>(<span class="pl-s1">torch</span>.<span class="pl-s1">multiprocessing</span>.<span class="pl-v">Pool</span>):
   <span class="pl-k">pass</span></pre></div>
<p dir="auto">Ends up with:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="TypeError: method expected 2 arguments, got 3"><pre class="notranslate">TypeError: method expected 2 arguments, got 3</pre></div>
<p dir="auto">This does makes sense, as it is not possible to subclass python's <code class="notranslate">multiprocessing.Pool</code> as well - but only <code class="notranslate">multiprocessing.pool.Pool</code>.<br>
<code class="notranslate">multiprocessing.Pool</code> is <strong>not</strong> a type, but rather a context method:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="print ( torch.multiprocessing.Pool)
#output:
&lt;bound method BaseContext.Pool of &lt;multiprocessing.context.DefaultContext object at 0x10f4bd550&gt;&gt;"><pre class="notranslate"><span class="pl-en">print</span> ( <span class="pl-s1">torch</span>.<span class="pl-s1">multiprocessing</span>.<span class="pl-v">Pool</span>)
<span class="pl-c">#output:</span>
<span class="pl-c1">&lt;</span><span class="pl-s1">bound</span> <span class="pl-s1">method</span> <span class="pl-v">BaseContext</span>.<span class="pl-v">Pool</span> <span class="pl-s1">of</span> <span class="pl-c1">&lt;</span><span class="pl-s1">multiprocessing</span>.<span class="pl-s1">context</span>.<span class="pl-v">DefaultContext</span> <span class="pl-s1">object</span> <span class="pl-s1">at</span> <span class="pl-c1">0x10f4bd550</span><span class="pl-c1">&gt;&gt;</span></pre></div>
<p dir="auto">The main problem is that <code class="notranslate">torch</code> doesn't expose the <code class="notranslate">torch.multiprocessing.pool</code> module - so it impossible to subclass <code class="notranslate">torch.multiprocessing.pool.Pool()</code></p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="AttributeError: module 'torch.multiprocessing' has no attribute 'pool'"><pre class="notranslate">AttributeError: module <span class="pl-s"><span class="pl-pds">'</span>torch.multiprocessing<span class="pl-pds">'</span></span> has no attribute <span class="pl-s"><span class="pl-pds">'</span>pool<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">This might be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="408799268" data-permission-text="Title is private" data-url="https://github.com/pytorch/pytorch/issues/16954" data-hovercard-type="issue" data-hovercard-url="/pytorch/pytorch/issues/16954/hovercard" href="https://github.com/pytorch/pytorch/issues/16954">#16954</a> - but I don't think it's a dupe, as the main problem here is exposing the <code class="notranslate">torch.pool</code> module.</p>
<h2 dir="auto">🐛 Bug</h2>
<p dir="auto">Trying to subclass:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class MyPool(torch.multiprocessing.Pool):
   pass"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">MyPool</span>(<span class="pl-s1">torch</span>.<span class="pl-s1">multiprocessing</span>.<span class="pl-v">Pool</span>):
   <span class="pl-k">pass</span></pre></div>
<p dir="auto">Ends up with:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="TypeError: method expected 2 arguments, got 3"><pre class="notranslate">TypeError: method expected 2 arguments, got 3</pre></div>
<p dir="auto">This does makes sense, as it is not possible to subclass python's <code class="notranslate">multiprocessing.Pool</code> as well - but only <code class="notranslate">multiprocessing.pool.Pool</code>.<br>
<code class="notranslate">multiprocessing.Pool</code> is <strong>not</strong> a type, but rather a context method:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="print ( torch.multiprocessing.Pool)
#output:
&lt;bound method BaseContext.Pool of &lt;multiprocessing.context.DefaultContext object at 0x10f4bd550&gt;&gt;"><pre class="notranslate"><span class="pl-en">print</span> ( <span class="pl-s1">torch</span>.<span class="pl-s1">multiprocessing</span>.<span class="pl-v">Pool</span>)
<span class="pl-c">#output:</span>
<span class="pl-c1">&lt;</span><span class="pl-s1">bound</span> <span class="pl-s1">method</span> <span class="pl-v">BaseContext</span>.<span class="pl-v">Pool</span> <span class="pl-s1">of</span> <span class="pl-c1">&lt;</span><span class="pl-s1">multiprocessing</span>.<span class="pl-s1">context</span>.<span class="pl-v">DefaultContext</span> <span class="pl-s1">object</span> <span class="pl-s1">at</span> <span class="pl-c1">0x10f4bd550</span><span class="pl-c1">&gt;&gt;</span></pre></div>
<p dir="auto">The main problem is that <code class="notranslate">torch</code> doesn't expose the <code class="notranslate">torch.multiprocessing.pool</code> module - so it impossible to subclass <code class="notranslate">torch.multiprocessing.pool.Pool()</code></p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="AttributeError: module 'torch.multiprocessing' has no attribute 'pool'"><pre class="notranslate">AttributeError: module <span class="pl-s"><span class="pl-pds">'</span>torch.multiprocessing<span class="pl-pds">'</span></span> has no attribute <span class="pl-s"><span class="pl-pds">'</span>pool<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">This might be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="408799268" data-permission-text="Title is private" data-url="https://github.com/pytorch/pytorch/issues/16954" data-hovercard-type="issue" data-hovercard-url="/pytorch/pytorch/issues/16954/hovercard" href="https://github.com/pytorch/pytorch/issues/16954">#16954</a> - but I don't think it's a dupe, as the main problem here is exposing the <code class="notranslate">torch.pool</code> module.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li><code class="notranslate">class MyPool(torch.multiprocessing.Pool):</code></li>
</ol>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">It should be possible to subclass torch's multiprocessing pool.</p>
<h2 dir="auto">Environment</h2>
<p dir="auto">PyTorch version: 1.0.0<br>
Is debug build: No<br>
CUDA used to build PyTorch: 9.0.176</p>
<p dir="auto">OS: Ubuntu 16.04 LTS,<br>
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609<br>
CMake version: Could not collect</p>
<p dir="auto">Python version: 3.6<br>
Is CUDA available: Yes<br>
CUDA runtime version: Could not collect<br>
GPU models and configuration: GPU 0: Tesla P100-PCIE-12GB<br>
Nvidia driver version: 390.30<br>
cuDNN version: Could not collect</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip3] numpy==1.14.3<br>
[pip3] torch==1.0.0<br>
[pip3] torchvision==0.2.1<br>
[conda] Could not collect</p>