code: def _infer_shape(output_shape, dimensions):
      """Replaces the -1 wildcard in the output shape vector.
  
      This function infers the correct output shape given the input dimensions.
  
      Args:
        output_shape: Output shape.
        dimensions: List of input non-batch dimensions.
  
      Returns:
        Tuple of non-batch output dimensions.
      """
      # Size of input.
      n = np.prod(dimensions)
      # Size of output where defined.
      v = np.array(output_shape)
      m = abs(np.prod(v))
      # Replace wildcard.
      v = [n // m if k == -1 else k for k in v]
      return tuple(v)
  
file_path: dm-haiku/haiku/_src/reshape.py
imports: from collections.abc import Sequence
  from typing import Optional
  from haiku._src import module
  import jax.numpy
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _infer_shape(output_shape, dimensions) and returns: tuple