code: def parse_memory(s):
      
      if isinstance(s, integer):
          out = s
      elif isinstance(s, float):
          out = math_ceil(s)
      elif isinstance(s, string):
          s = s.replace(' ', '')
  
          if not s:
              raise context.ValueError("Could not interpret %r as a byte unit" % s)
  
          if s[0].isdigit():
              for i, c in enumerate(reversed(s)):
                  if not c.isalpha():
                      break
  
              index = len(s) - i
              prefix = s[:index]
              suffix = s[index:]
  
              try:
                  n = float(prefix)
              except ValueError:
                  raise context.ValueError("Could not interpret %r as a number" % prefix)
          else:
              n = 1
              suffix = s
  
          try:
              multiplier = _byte_sizes[suffix.lower()]
          except KeyError:
              raise context.ValueError("Could not interpret %r as a byte unit" % suffix)
  
          out = math_ceil(n * multiplier / (2 ** 20))
      else:
          raise context.TypeError("memory must be an integer, got %r"
                                  % type(s).__name__)
  
      if out < 0:
          raise context.ValueError("memory must be positive")
  
      return out
docs: Converts bytes expression to number of mebibytes.
  
      If no unit is specified, ``MiB`` is used.