{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"ds-1000","formal_name":"DS-1000","introduction":"DS-1000 builds 1,000 data-science problems from real StackOverflow questions across seven libraries including NumPy, Pandas and Matplotlib. The problems are perturbed so that recalling the original answer does not solve them.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://ds1000-code-gen.github.io/","indexing_mode":"index","profile":{"resources":[],"task_format":"","scoring":"","metric":"","size":"","answer_access":"","license":"","citation":"","maintainer":"","released":"","why_hard":"","related":[],"history":"","construction":"","limitations":"","saturation":"","scores":[]}},"task_id":"689326d2-b07b-5fd2-ae11-04d0385ad339","task_key":"default--test--504","task_revision_id":"1","upstream_id":"504","short_description":"I have two arrays:","config":"default","split":"test","body":"{\"library\":\"Numpy\",\"prompt\":\"Problem:\\nI have two arrays:\\n•\\ta: a 3-dimensional source array (N x M x T)\\n•\\tb: a 2-dimensional index array (N x M) containing 0, 1, … T-1s.\\nI want to use the indices in b to compute sum of corresponding elements of a in its third dimension. Here is the example as code:\\nimport numpy as np\\na = np.array( # dims: 3x3x4\\n    [[[ 0,  1, 2, 3],\\n     [ 2,  3, 4, 5],\\n     [ 4,  5, 6, 7]],\\n    [[ 6,  7, 8, 9],\\n     [ 8,  9, 10, 11],\\n     [10, 11, 12, 13]],\\n    [[12, 13, 14, 15],\\n     [14, 15, 16, 17],\\n     [16, 17, 18, 19]]]\\n)\\nb = np.array( # dims: 3x3\\n    [[0, 1, 2],\\n    [2, 1, 3],\\n[1, 0, 3]]\\n)\\n# select and sum the elements in a according to b\\n# to achieve this result:\\ndesired = 85\\n\\nAt first, I thought this must have a simple solution but I could not find one at all. Since I would like to port it to tensorflow, I would appreciate if somebody knows a numpy-type solution for this.\\nA:\\n<code>\\nimport numpy as np\\na = np.array( \\n    [[[ 0,  1, 2, 3],\\n     [ 2,  3, 4, 5],\\n     [ 4,  5, 6, 7]],\\n    [[ 6,  7, 8, 9],\\n     [ 8,  9, 10, 11],\\n     [10, 11, 12, 13]],\\n    [[12, 13, 14, 15],\\n     [14, 15, 16, 17],\\n     [16, 17, 18, 19]]]\\n)\\nb = np.array( \\n    [[0, 1, 2],\\n    [2, 1, 3],\\n[1, 0, 3]]\\n)\\n</code>\\nresult = ... # put solution in this variable\\nBEGIN SOLUTION\\n<code>\\n\"}","display_format":"code","language":"","answer_status":"published","assets":[],"source_url":"https://ds1000-code-gen.github.io/","history":"initial import","indexing_mode":"index","subproblems":[],"grids":[]}