from typing import Any
import string


def _normalize_mpn(mpn: Any,
                   charset: str = string.ascii_letters + string.digits) -> str:
  """Returns the provided text in lowercase with chars not in charset removed.

  Examples:
    "100" should return "100"
    "no value" should return "novalue"
    "n/a" should return "na"
    "N/A" should return "na"
    None should return ""

  Args:
    mpn: A value that represents the product's MPN.
    charset: the set of characters to include in the result text

  Returns:
    Input text converted to lowercase and characters not in the charset stripped
    out.
  """
  if not isinstance(mpn, str):
    return ''
  normalized_mpn = ''.join(char for char in mpn if char in charset)
  normalized_mpn = normalized_mpn.lower()
  return normalized_mpn