code: def _compute_fans(shape, data_format="channels_first"):
      """Computes the number of input and output units for a weight shape.
      # Arguments
          shape: Integer shape tuple.
          data_format: Image data format to use for convolution kernels.
              Note that all kernels in Keras are standardized on the
              `channels_last` ordering (even when inputs are set
              to `channels_first`).
      # Returns
          A tuple of scalars, `(fan_in, fan_out)`.
      # Raises
          ValueError: in case of invalid `data_format` argument.
      """
      if len(shape) == 2:
          fan_in = shape[0]
          fan_out = shape[1]
      elif len(shape) in {3, 4, 5}:
          # Assuming convolution kernels (1D, 2D or 3D).
          # TH kernel shape: (depth, input_depth, ...)
          # TF kernel shape: (..., input_depth, depth)
          if data_format == "channels_first":
              receptive_field_size = np.prod(shape[2:])
              fan_in = shape[1] * receptive_field_size
              fan_out = shape[0] * receptive_field_size
          elif data_format == "channels_last":
              receptive_field_size = np.prod(shape[:-2])
              fan_in = shape[-2] * receptive_field_size
              fan_out = shape[-1] * receptive_field_size
          else:
              raise ValueError("Invalid data_format: " + data_format)
      else:
          # No specific assumptions.
          fan_in = np.sqrt(np.prod(shape))
          fan_out = np.sqrt(np.prod(shape))
      return fan_in, fan_out
  
file_path: singa/python/singa/initializer.py
imports: from __future__ import division
  import math
  import numpy
  from deprecated import deprecated
label_desc: Use image node_id 13 for calling a global function with example usage: _compute_fans(shape, data_format) and returns: fan_in,  fan_out