code: def _end_sessions(self, session_ids):
          
          try:
              # Use SocketInfo.command directly to avoid implicitly creating
              # another session.
              with self._socket_for_reads(
                      ReadPreference.PRIMARY_PREFERRED,
                      None) as (sock_info, slave_ok):
                  if not sock_info.supports_sessions:
                      return
  
                  for i in range(0, len(session_ids), common._MAX_END_SESSIONS):
                      spec = SON([('endSessions',
                                   session_ids[i:i + common._MAX_END_SESSIONS])])
                      sock_info.command(
                          'admin', spec, slave_ok=slave_ok, client=self)
          except PyMongoError:
              # Drivers MUST ignore any errors returned by the endSessions
              # command.
              pass
docs: Send endSessions command(s) with the given session ids.