code: def _replace_nan(M: BlockMatrix, value: float) -> BlockMatrix:
      """Replace NaN entries in a dense :class:`.BlockMatrix` with provided value.
  
      Parameters
      ----------
      M: :class:`.BlockMatrix`
      value: :obj:`float`
          Value to replace NaN entries with.
  
      Returns
      -------
      :class:`.BlockMatrix`
      """
      return M._map_dense(lambda x: hl.if_else(hl.is_nan(x), value, x))
  
imports: from typing import Optional
  import hail
  import hail.expr.aggregators
  from hail import ir
  from hail.backend.spark_backend import SparkBackend
  from hail.expr import ArrayNumericExpression, BooleanExpression, CallExpression, Float64Expression, analyze, expr_array, expr_call, expr_float64, matrix_table_source
  from hail.expr.types import tarray
  from hail.linalg import BlockMatrix
  from hail.table import Table
  from hail.typecheck import enumeration, nullable, numeric, typecheck
  from hail.utils import new_temp_file
  from hail.utils.java import Env
  from ..pca import _hwe_normalized_blanczos, hwe_normalized_pca
label_desc: Use image node_id 6 for calling a global function with example usage: _replace_nan(M, value) and returns: M