def transform_block(block, scale, translation):
  """Transform a block by a specified scale and translation.

  This scales BOTH the width/height as well as the x and y positions, and THEN
  performs the translation.

  Args:
    block: Block object
    scale: a tuple/list of length two, corresponding to the scale of the x and
      y dimensions
    translation: a tuple/list of length two, corresponding to the translation
      in the x and y dimensions

  Returns:
    block: a scaled Block object
  """
  if block is None:
    return None
  if block.x is None:
    x = None
  else:
    x = (block.x * scale[0]) + translation[0]
  if block.y is None:
    y = None
  else:
    y = (block.y * scale[1]) + translation[1]
  width = block.width * scale[0]
  height = block.height * scale[1]

  return block._replace(x=x, y=y, width=width, height=height)