code: def hist_series(
      self: Series,
      by=None,
      ax=None,
      grid: bool = True,
      xlabelsize: int | None = None,
      xrot=None,
      ylabelsize: int | None = None,
      yrot=None,
      figsize: tuple[float, float] | None = None,
      bins: int = 10,
      legend: bool = False,
      **kwds,
  ):
      import matplotlib.pyplot as plt
  
      if legend and "label" in kwds:
          raise ValueError("Cannot use both legend and label")
  
      if by is None:
          if kwds.get("layout", None) is not None:
              raise ValueError(
                  "The 'layout' keyword is not supported when 'by' is None"
              )
          # hack until the plotting interface is a bit more unified
          fig = kwds.pop(
              "figure",
              plt.gcf()
              if plt.get_fignums()
              else plt.figure(figsize=figsize),
          )
          if figsize is not None and tuple(figsize) != tuple(
              fig.get_size_inches()
          ):
              fig.set_size_inches(*figsize, forward=True)
          if ax is None:
              ax = fig.gca()
          elif ax.get_figure() != fig:
              raise AssertionError(
                  "passed axis not bound to passed figure"
              )
          values = self.dropna().values
          if legend:
              kwds["label"] = self.name
          ax.hist(values, bins=bins, **kwds)
          if legend:
              ax.legend()
          ax.grid(grid)
          axes = np.array([ax])
  
          set_ticks_props(
              axes,
              xlabelsize=xlabelsize,
              xrot=xrot,
              ylabelsize=ylabelsize,
              yrot=yrot,
          )
  
      else:
          if "figure" in kwds:
              raise ValueError(
                  "Cannot pass 'figure' when using the "
                  "'by' argument, since a new 'Figure' instance will be created"
              )
          axes = _grouped_hist(
              self,
              by=by,
              ax=ax,
              grid=grid,
              figsize=figsize,
              bins=bins,
              xlabelsize=xlabelsize,
              xrot=xrot,
              ylabelsize=ylabelsize,
              yrot=yrot,
              legend=legend,
              **kwds,
          )
  
      if hasattr(axes, "ndim"):
          if axes.ndim == 1 and len(axes) == 1:
              return axes[0]
      return axes
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any, Literal, final
  import numpy
  from pandas.core.dtypes.common import is_integer, is_list_like
  from pandas.core.dtypes.generic import ABCDataFrame, ABCIndex
  from pandas.core.dtypes.missing import isna, remove_na_arraylike
  from pandas.io.formats.printing import pprint_thing
  from pandas.plotting._matplotlib.core import LinePlot, MPLPlot
  from pandas.plotting._matplotlib.groupby import create_iter_data_given_by, reformat_hist_y_given_by
  from pandas.plotting._matplotlib.misc import unpack_single_str_list
  from pandas.plotting._matplotlib.tools import create_subplots, flatten_axes, maybe_adjust_figure, set_ticks_props
label_desc: Use image node_id 3 for calling a global function with example usage: hist_series(by, ax, grid, xlabelsize, xrot, ylabelsize, yrot, figsize, bins, legend) and returns: axes, axes