original_docstring: Helper which checks validity of `loc` and `scale` init args.
docstring: Helper which checks validity of `loc` and `scale` init args.
docstring_tokens: Helper which checks validity of ` loc ` and ` scale ` init args .
code: def maybe_check_quadrature_param(param, name, validate_args):
    """Helper which checks validity of `loc` and `scale` init args."""
    with ops.name_scope(name="check_" + name, values=[param]):
      assertions = []
      if param.shape.ndims is not None:
        if param.shape.ndims == 0:
          raise ValueError("Mixing params must be a (batch of) vector; "
                           "{}.rank={} is not at least one.".format(
                               name, param.shape.ndims))
      elif validate_args:
        assertions.append(check_ops.assert_rank_at_least(
            param, 1,
            message=("Mixing params must be a (batch of) vector; "
                     "{}.rank is not at least one.".format(
                         name))))
  
      # TODO(jvdillon): Remove once we support k-mixtures.
      if param.shape.with_rank_at_least(1)[-1] is not None:
        if param.shape[-1].value != 1:
          raise NotImplementedError("Currently only bimixtures are supported; "
                                    "{}.shape[-1]={} is not 1.".format(
                                        name, param.shape[-1].value))
      elif validate_args:
        assertions.append(check_ops.assert_equal(
            array_ops.shape(param)[-1], 1,
            message=("Currently only bimixtures are supported; "
                     "{}.shape[-1] is not 1.".format(name))))
  
      if assertions:
        return control_flow_ops.with_dependencies(assertions, param)
      return param
code_tokens: def maybe_check_quadrature_param ( param , name , validate_args ) : with ops . name_scope ( name = "check_" + name , values = [ param ] ) : assertions = [ ] if param . shape . ndims is not None : if param . shape . ndims == 0 : raise ValueError ( "Mixing params must be a (batch of) vector; " "{}.rank={} is not at least one." . format ( name , param . shape . ndims ) ) elif validate_args : assertions . append ( check_ops . assert_rank_at_least ( param , 1 , message = ( "Mixing params must be a (batch of) vector; " "{}.rank is not at least one." . format ( name ) ) ) ) if param . shape . with_rank_at_least ( 1 ) [ - 1 ] is not None : if param . shape [ - 1 ] . value != 1 : raise NotImplementedError ( "Currently only bimixtures are supported; " "{}.shape[-1]={} is not 1." . format ( name , param . shape [ - 1 ] . value ) ) elif validate_args : assertions . append ( check_ops . assert_equal ( array_ops . shape ( param ) [ - 1 ] , 1 , message = ( "Currently only bimixtures are supported; " "{}.shape[-1] is not 1." . format ( name ) ) ) ) if assertions : return control_flow_ops . with_dependencies ( assertions , param ) return param
short_docstring: Helper which checks validity of `loc` and `scale` init args.
short_docstring_tokens: Helper which checks validity of ` loc ` and ` scale ` init args .
comment: """Helper which checks validity of `loc` and `scale` init args."""$SEP$# TODO(jvdillon): Remove once we support k-mixtures.