code: def to_time(
      arg, format=None, infer_time_format=False, errors="raise"
  ):
      """
      Parse time strings to time objects using fixed strptime formats ("%H:%M",
      "%H%M", "%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p",
      "%I%M%S%p")
  
      Use infer_time_format if all the strings are in the same format to speed
      up conversion.
  
      Parameters
      ----------
      arg : string in time format, datetime.time, list, tuple, 1-d array,  Series
      format : str, default None
          Format used to convert arg into a time object.  If None, fixed formats
          are used.
      infer_time_format: bool, default False
          Infer the time format based on the first non-NaN element.  If all
          strings are in the same format, this will speed up conversion.
      errors : {'ignore', 'raise', 'coerce'}, default 'raise'
          - If 'raise', then invalid parsing will raise an exception
          - If 'coerce', then invalid parsing will be set as None
          - If 'ignore', then invalid parsing will return the input
  
      Returns
      -------
      datetime.time
      """
      from pandas.core.series import Series
  
      def _convert_listlike(arg, format):
          if isinstance(arg, (list, tuple)):
              arg = np.array(arg, dtype="O")
  
          elif getattr(arg, "ndim", 1) > 1:
              raise TypeError(
                  "arg must be a string, datetime, list, tuple, "
                  "1-d array, or Series"
              )
  
          arg = ensure_object(arg)
  
          if infer_time_format and format is None:
              format = _guess_time_format_for_array(arg)
  
          times = []
          if format is not None:
              for element in arg:
                  try:
                      times.append(
                          datetime.strptime(element, format).time()
                      )
                  except (ValueError, TypeError):
                      if errors == "raise":
                          msg = (
                              "Cannot convert {element} to a time with given "
                              "format {format}"
                          ).format(element=element, format=format)
                          raise ValueError(msg)
                      elif errors == "ignore":
                          return arg
                      else:
                          times.append(None)
          else:
              formats = _time_formats[:]
              format_found = False
              for element in arg:
                  time_object = None
                  for time_format in formats:
                      try:
                          time_object = datetime.strptime(
                              element, time_format
                          ).time()
                          if not format_found:
                              # Put the found format in front
                              fmt = formats.pop(
                                  formats.index(time_format)
                              )
                              formats.insert(0, fmt)
                              format_found = True
                          break
                      except (ValueError, TypeError):
                          continue
  
                  if time_object is not None:
                      times.append(time_object)
                  elif errors == "raise":
                      raise ValueError(
                          "Cannot convert arg {arg} to "
                          "a time".format(arg=arg)
                      )
                  elif errors == "ignore":
                      return arg
                  else:
                      times.append(None)
  
          return times
  
      if arg is None:
          return arg
      elif isinstance(arg, time):
          return arg
      elif isinstance(arg, Series):
          values = _convert_listlike(arg._values, format)
          return Series(values, index=arg.index, name=arg.name)
      elif isinstance(arg, ABCIndexClass):
          return _convert_listlike(arg, format)
      elif is_list_like(arg):
          return _convert_listlike(arg, format)
  
      return _convert_listlike(np.array([arg]), format)[0]
  
imports: from datetime import datetime, time
  from functools import partial
  import numpy
  from pandas._libs import tslib, tslibs
  from pandas._libs.tslibs import Timestamp, conversion, parsing
  from pandas._libs.tslibs.parsing import DateParseError, _format_is_iso, _guess_datetime_format, parse_time_string
  from pandas._libs.tslibs.strptime import array_strptime
  from pandas.compat import zip
  from pandas.core.dtypes.common import ensure_object, is_datetime64_dtype, is_datetime64_ns_dtype, is_datetime64tz_dtype, is_float, is_integer, is_integer_dtype, is_list_like, is_numeric_dtype, is_object_dtype, is_scalar
  from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
  from pandas.core.dtypes.missing import notna
  from pandas import compat
  from pandas.core import algorithms
label_desc: Use image node_id 11 for calling a global function with example usage: to_time(arg, format, infer_time_format, errors) and returns: _convert_listlike, times, arg, arg, Series, _convert_listlike, _convert_listlike, arg, arg