code: def _infer_shape(
      output_shape: types.ShapeLike, dimensions: Sequence[int]
  ):
      """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[v == -1] = n // m
      return tuple(v)
  
file_path: sonnet/sonnet/src/reshape.py
imports: from typing import Optional, Sequence
  import numpy
  from sonnet.src import base
  from sonnet.src import once
  from sonnet.src import types
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: _infer_shape(output_shape, dimensions) and returns: tuple