code: def mercator_transform(
      data: Any,
      lat_bounds: Tuple[float, float],
      origin: str = "upper",
      height_out: Optional[int] = None,
  ) -> np.ndarray:
      """
      Transforms an image computed in (longitude,latitude) coordinates into
      the a Mercator projection image.
  
      Parameters
      ----------
  
      data: numpy array or equivalent list-like object.
          Must be NxM (mono), NxMx3 (RGB) or NxMx4 (RGBA)
  
      lat_bounds : length 2 tuple
          Minimal and maximal value of the latitude of the image.
          Bounds must be between -85.051128779806589 and 85.051128779806589
          otherwise they will be clipped to that values.
  
      origin : ['upper' | 'lower'], optional, default 'upper'
          Place the [0,0] index of the array in the upper left or lower left
          corner of the axes.
  
      height_out : int, default None
          The expected height of the output.
          If None, the height of the input is used.
  
      See https://en.wikipedia.org/wiki/Web_Mercator for more details.
  
      """
  
      def mercator(x):
          return np.arcsinh(np.tan(x * np.pi / 180.0)) * 180.0 / np.pi
  
      array = np.atleast_3d(data).copy()
      height, width, nblayers = array.shape
  
      lat_min = max(lat_bounds[0], -85.051128779806589)
      lat_max = min(lat_bounds[1], 85.051128779806589)
      if height_out is None:
          height_out = height
  
      # Eventually flip the image
      if origin == "upper":
          array = array[::-1, :, :]
  
      lats = lat_min + np.linspace(
          0.5 / height, 1.0 - 0.5 / height, height
      ) * (lat_max - lat_min)
      latslats = mercator(lat_min) + np.linspace(
          0.5 / height_out, 1.0 - 0.5 / height_out, height_out
      ) * (mercator(lat_max) - mercator(lat_min))
  
      out = np.zeros((height_out, width, nblayers))
      for i in range(width):
          for j in range(nblayers):
              out[:, i, j] = np.interp(
                  latslats, mercator(lats), array[:, i, j]
              )
  
      # Eventually flip the image.
      if origin == "upper":
          out = out[::-1, :, :]
      return out
  
imports: import base64
  import collections
  import copy
  import json
  import math
  import os
  import re
  import tempfile
  import uuid
  from contextlib import contextmanager
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple, Type, Union
  from urllib.parse import urlparse, uses_netloc, uses_params, uses_relative
  import numpy
  from branca.element import Element, Figure
  from branca.utilities import _locations_mirror, _parse_size, none_max, none_min, write_png
label_desc: Use image node_id 8 for calling a global function with example usage: mercator_transform(data, lat_bounds, origin, height_out) and returns: out, unknown