original_docstring: Helper which interpolates between two locs.
docstring: Helper which interpolates between two locs.
docstring_tokens: Helper which interpolates between two locs .
code: def interpolate_loc(grid, loc):
    """Helper which interpolates between two locs."""
    if len(loc) != 2:
      raise NotImplementedError("Currently only bimixtures are supported; "
                                "len(scale)={} is not 2.".format(len(loc)))
    deg = grid.shape.with_rank_at_least(1)[-1].value
    if deg is None:
      raise ValueError("Num quadrature grid points must be known prior "
                       "to graph execution.")
    with ops.name_scope("interpolate_loc", values=[grid, loc]):
      if loc is None or loc[0] is None and loc[1] is None:
        return [None]*deg
      # shape: [B, 1, k, deg]
      w = grid[..., array_ops.newaxis, :, :]
      loc = [x[..., array_ops.newaxis]                   # shape: [B, e, 1]
             if x is not None else None for x in loc]
      if loc[0] is None:
        x = w[..., 1, :] * loc[1]                        # shape: [B, e, deg]
      elif loc[1] is None:
        x = w[..., 0, :] * loc[0]                        # shape: [B, e, deg]
      else:
        delta = loc[0] - loc[1]
        x = w[..., 0, :] * delta + loc[1]                # shape: [B, e, deg]
      return [x[..., k] for k in range(deg)]             # list(shape:[B, e])
code_tokens: def interpolate_loc ( grid , loc ) : if len ( loc ) != 2 : raise NotImplementedError ( "Currently only bimixtures are supported; " "len(scale)={} is not 2." . format ( len ( loc ) ) ) deg = grid . shape . with_rank_at_least ( 1 ) [ - 1 ] . value if deg is None : raise ValueError ( "Num quadrature grid points must be known prior " "to graph execution." ) with ops . name_scope ( "interpolate_loc" , values = [ grid , loc ] ) : if loc is None or loc [ 0 ] is None and loc [ 1 ] is None : return [ None ] * deg w = grid [ ... , array_ops . newaxis , : , : ] loc = [ x [ ... , array_ops . newaxis ] if x is not None else None for x in loc ] if loc [ 0 ] is None : x = w [ ... , 1 , : ] * loc [ 1 ] elif loc [ 1 ] is None : x = w [ ... , 0 , : ] * loc [ 0 ] else : delta = loc [ 0 ] - loc [ 1 ] x = w [ ... , 0 , : ] * delta + loc [ 1 ] return [ x [ ... , k ] for k in range ( deg ) ]
short_docstring: Helper which interpolates between two locs.
short_docstring_tokens: Helper which interpolates between two locs .
comment: """Helper which interpolates between two locs."""$SEP$# shape: [B, 1, k, deg]$SEP$# shape: [B, e, 1]$SEP$# shape: [B, e, deg]$SEP$# shape: [B, e, deg]$SEP$# shape: [B, e, deg]$SEP$# list(shape:[B, e])