code: def _replace(
      df_or_series,
      to_replace=None,
      value=None,
      inplace=False,
      limit=None,
      regex=False,
      method=no_default,
  ):
      if (
          not isinstance(to_replace, dict)
          and value is no_default
          and limit is not None
      ):
          raise NotImplementedError(
              "fill with limit not supported when value is None"
          )
  
      if not isinstance(regex, bool):
          to_replace = regex
          regex = True
      op = DataFrameReplace(
          to_replace=to_replace,
          value=value,
          limit=limit,
          regex=regex,
          method=method,
      )
      ret = op(df_or_series)
      if inplace:
          df_or_series.data = ret.data
      else:
          return ret
  
imports: import numpy
  import pandas
  from ...None import opcodes
  from ...core import recursive_tile
  from ...core.operand import OperandStage
  from ...serialization.serializables import FieldTypes, AnyField, Int32Field, ListField
  from ...utils import no_default
  from ..operands import DataFrameOperand, DataFrameOperandMixin, SERIES_TYPE, SERIES_CHUNK_TYPE
  from ..utils import build_df, build_series, parse_index
label_desc: Use image node_id 1 for calling a global function with example usage: _replace(df_or_series, to_replace, value, inplace, limit, regex, method) and returns: ret