code: def graph_to_shapely(
      gdf: gp.GeoDataFrame, width: float = 1.0
  ) -> BaseGeometry:
      """
      Given a GeoDataFrame containing a graph (street newtork),
      convert them to shapely geometries by applying dilation given by 'width'
  
      Args:
          gdf (gp.GeoDataFrame): input GeoDataFrame containing graph (street network) geometries
          width (float, optional): Line geometries will be dilated by this amount. Defaults to 1..
  
      Returns:
          BaseGeometry: Shapely
      """
  
      def highway_to_width(highway):
          if (type(highway) == str) and (highway in width):
              return width[highway]
          elif isinstance(highway, Iterable):
              for h in highway:
                  if h in width:
                      return width[h]
              return np.nan
          else:
              return np.nan
  
      # Annotate GeoDataFrame with the width for each highway type
      gdf["width"] = (
          gdf.highway.map(highway_to_width)
          if type(width) == dict
          else width
      )
  
      # Remove rows with inexistent width
      gdf.drop(gdf[gdf.width.isna()].index, inplace=True)
  
      with warnings.catch_warnings():
          # Supress shapely.errors.ShapelyDeprecationWarning
          warnings.simplefilter(
              "ignore", shapely.errors.ShapelyDeprecationWarning
          )
          if not all(gdf.width.isna()):
              # Dilate geometries based on their width
              gdf.geometry.update(
                  gdf.apply(
                      lambda row: row.geometry.buffer(row.width), axis=1
                  )
              )
  
      return shapely.ops.unary_union(gdf.geometry)
  
imports: import re
  import os
  import json
  import yaml
  import pathlib
  import warnings
  import matplotlib
  import shapely.ops
  import numpy
  import osmnx
  import pandas
  import geopandas
  import shapely.affinity
  from copy import deepcopy
  from .fetch import get_gdfs
  from dataclasses import dataclass
  from matplotlib import pyplot
  from matplotlib.colors import hex2color
  from matplotlib.patches import Path, PathPatch
  from typing import Optional, Union, Tuple, List, Dict, Any, Iterable
  from shapely.geometry.base import BaseGeometry
  from shapely.geometry import Point, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection, box
label_desc: Use image node_id 5 for calling a global function with example usage: graph_to_shapely(gdf, width) and returns: shapely, width, np, np, width