from yacl_base import get

def MB(x):
  return int(x * 1024 * 1024)

def ternary_eq(attrib_name, equal_to, then, else_):
  def f():
    if get(attrib_name) == equal_to:
      return then
    else:
      return else_
  return f

def ternary_in(attrib_name, in_list, then, else_):
  def f():
    if get(attrib_name) in in_list:
      return then
    else:
      return else_
  return f
