code: def indices_to_mask(indices, shape, dtype=tf.bool):
      """
      Return mask with true values at indices of the given shape.
      This can be used as an inverse to tf.where.
      :param indices: [nnz, k] or [nnz] Tensor indices of True values.
      :param shape: [k] or [] (scalar) Tensor shape/size of output.
      :param dtype: dtype of the output.
      :return: Tensor of given shape and dtype.
      """
      indices = tf.convert_to_tensor(indices, dtype_hint=tf.int64)
      if indices.shape.ndims == 1:
          assert isinstance(shape, int) or shape.shape.ndims == 0
          indices = tf.expand_dims(indices, axis=1)
          if isinstance(shape, int):
              shape = tf.TensorShape([shape])
          else:
              shape = tf.expand_dims(shape, axis=0)
      else:
          indices.shape.assert_has_rank(2)
      assert indices.dtype.is_integer
      nnz = tf.shape(indices)[0]
      indices = tf.cast(indices, tf.int64)
      shape = tf.cast(shape, tf.int64)
      return tf.scatter_nd(indices, tf.ones((nnz,), dtype=dtype), shape)
  
imports: import numpy
  import tensorflow
  from tensorflow.keras import backend
label_desc: Use image node_id 5 for calling a global function with example usage: indices_to_mask(indices, shape, dtype) and returns: tf