TensorOperator's compute method is used to realize underlying cached_data, which is of Type NDArray. However, Stack's type hint imply that the return value is a Tensor.
class Value:
"""A value in the computational graph."""
# trace of computational graph
op: Optional[Op]
inputs: List["Value"]
# The following fields are cached fields for
# dynamic computation
cached_data: NDArray
requires_grad: bool
class Stack(TensorOp):
def __init__(self, axis: int):
"""
Concatenates a sequence of arrays along a new dimension.
Parameters:
axis - dimension to concatenate along
All arrays need to be of the same size.
"""
self.axis = axis
def compute(self, args: TensorTuple) -> Tensor:
### BEGIN YOUR SOLUTION
raise NotImplementedError()
### END YOUR SOLUTION
def gradient(self, out_grad, node):
### BEGIN YOUR SOLUTION
raise NotImplementedError()
### END YOUR SOLUTION