parameters: (name, value, data_format, default_value=1)
return_statement: return value[1:4]
docstring: Compute strides or dilation values for 2D and 3D convolutions.
docstring_summary: Compute strides or dilation values for 2D and 3D convolutions.
docstring_tokens: Compute strides or dilation values for 2D and 3D convolutions .
function: def _conv2d3d_strides_or_dilations(name, value, data_format, default_value=1):
      """Compute strides or dilation values for 2D and 3D convolutions."""
      if value is None:
          value = default_value
      if not isinstance(value, (int, list)):
          raise ValueError("{} must be an int or list".format(name))
  
      # Parse number of spatial dimensions from `data_format`, assuming N (batch) and C
      # (input channels) are present
      n_dims = len(data_format) - 2
  
      if isinstance(value, int):
          return [value] * n_dims
  
      if len(value) == 1:
          return value * n_dims
      if len(value) == n_dims:
          return value
      if len(value) != n_dims + 2:
          raise ValueError(
              "{} must have length 1, {}, or {}".format(name, n_dims, n_dims + 2)
          )
  
      if data_format == "NHWC":
          # Only support stride/dilation along N, C == 1
          if not (value[0] == value[3] == 1):
              raise ValueError(
                  "{} along N and C other than 1 not implemented".format(name)
              )
          return value[1:3]
      elif data_format == "NCHW" or data_format == "NCDHW":
          if not (value[0] == value[1] == 1):
              raise ValueError(
                  "{} along N and C other than 1 not implemented".format(name)
              )
          return value[2:]
      # "NDHWC"
      if not (value[0] == value[4] == 1):
          raise ValueError("{} along N and C other than 1 not implemented".format(name))
      return value[1:4]
function_tokens: def _conv2d3d_strides_or_dilations ( name , value , data_format , default_value = 1 ) : if value is None : value = default_value if not isinstance ( value , ( int , list ) ) : raise ValueError ( "{} must be an int or list" . format ( name ) ) # Parse number of spatial dimensions from `data_format`, assuming N (batch) and C # (input channels) are present n_dims = len ( data_format ) - 2 if isinstance ( value , int ) : return [ value ] * n_dims if len ( value ) == 1 : return value * n_dims if len ( value ) == n_dims : return value if len ( value ) != n_dims + 2 : raise ValueError ( "{} must have length 1, {}, or {}" . format ( name , n_dims , n_dims + 2 ) ) if data_format == "NHWC" : # Only support stride/dilation along N, C == 1 if not ( value [ 0 ] == value [ 3 ] == 1 ) : raise ValueError ( "{} along N and C other than 1 not implemented" . format ( name ) ) return value [ 1 : 3 ] elif data_format == "NCHW" or data_format == "NCDHW" : if not ( value [ 0 ] == value [ 1 ] == 1 ) : raise ValueError ( "{} along N and C other than 1 not implemented" . format ( name ) ) return value [ 2 : ] # "NDHWC" if not ( value [ 0 ] == value [ 4 ] == 1 ) : raise ValueError ( "{} along N and C other than 1 not implemented" . format ( name ) ) return value [ 1 : 4 ]