code: def _compute_fans_from_shape(shape, batch_ndims=0):
      """Extracts `fan_in, fan_out` from specified shape `Tensor`."""
      # Ensure shape is a vector of length >=2.
      num_pad = prefer_static.maximum(0, 2 - prefer_static.size(shape))
      shape = prefer_static.pad(
          shape, paddings=[[0, num_pad]], constant_values=1
      )
      (
          batch_shape,  # pylint: disable=unused-variable
          extra_shape,
          fan_in,
          fan_out,
      ) = prefer_static.split(shape, [batch_ndims, -1, 1, 1])
      # The following logic is primarily intended for convolutional layers which
      # have spatial semantics in addition to input/output channels.
      receptive_field_size = prefer_static.reduce_prod(extra_shape)
      fan_in = fan_in[0] * receptive_field_size
      fan_out = fan_out[0] * receptive_field_size
      return fan_in, fan_out
  
file_path: probability/tensorflow_probability/python/experimental/nn/initializers/initializers.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
label_desc: Use image node_id 6 for calling a global function with example usage: _compute_fans_from_shape(shape, batch_ndims) and returns: fan_in,  fan_out